SELECT tx5_users.id userid, tx5_users.username username, tx5_users.oldrank oldrank, tx5_users.alliance alliance, (
SELECT SUM( tx5_vdata.pop )
FROM tx5_vdata
WHERE tx5_vdata.owner = userid
)totalpop, (
SELECT COUNT( tx5_vdata.wref )
FROM tx5_vdata
WHERE tx5_vdata.owner = userid AND type != 99
)totalvillages, (
SELECT tx5_alidata.tag
FROM tx5_alidata, tx5_users
WHERE tx5_alidata.id = tx5_users.alliance
AND tx5_users.id = userid
)allitag
FROM tx5_users
WHERE tx5_users.access < " . (INCLUDE_ADMIN ? "10" : "8") . "
AND tx5_users.tribe <= 3 ORDER BY totalpop DESC, totalvillages DESC, userid DESC
SELECT tx5_users.id userid, tx5_users.username username, tx5_users.dpall, (
SELECT COUNT( tx5_vdata.wref )
FROM tx5_vdata
WHERE tx5_vdata.owner = userid AND type != 99
)totalvillages, (
SELECT SUM( tx5_vdata.pop )
FROM tx5_vdata
WHERE tx5_vdata.owner = userid
)pop
FROM tx5_users
WHERE tx5_users.dpall >=0 AND tx5_users.access < " . (INCLUDE_ADMIN ? "10" : "8") . " AND tx5_users.tribe <= 3
ORDER BY tx5_users.dpall DESC, pop DESC, userid DESC
Остальные запросы очень похожи на эти два...