下面这个查询与我的氏族排名 php 脚本相关联。
SELECT TOP 100
IDNum,
IDName,
Nation,
(SELECT SUM(LoyaltyPoint)
FROM USERDATA
WHERE USERDATA.Knights = KNIGHTS.IDNum
AND USERDATA.Authority IN(1, 2)) as ClanLoyalty
FROM KNIGHTS
ORDER BY ClanLoyalty DESC
我想为MannerPoint
忠诚度添加第二条规则。因此,它将同时显示礼貌点和忠诚点,并按两者排序。
例如,如果氏族有10000忠诚度和100礼仪,那么它的排名会高于20000忠诚度和只有50礼仪的排名。
我尝试了一些但失败了。如果有人愿意帮助我,将不胜感激。
编辑:我试过了:
SELECT TOP 100 IDNum, IDName, Nation, (SELECT SUM(LoyaltyPoint) FROM USERDATA WHERE USERDATA.Knights = KNIGHTS.IDNum AND USERDATA.Authority IN(1, 2)) as ClanLoyalty, (SELECT SUM(MannerPoint) FROM USERDATA WHERE USERDATA.Knights = KNIGHTS.IDNum AND USERDATA.Authority IN(1, 2))) as MannerPoint FROM KNIGHTS ORDER BY ClanLoyalty DESC, MannerPoint DESC
但它根本不显示。