-2

此查询在我的氏族 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

LoyaltyPoint但我想在第二条规则之上添加MannerPoint.

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

但这不起作用并且不显示。

我使用 MSSQL 2005

4

1 回答 1

1

你在这里有一个额外的括号;

AND USERDATA.Authority IN(1, 2)) ) as MannerPoint

删除了额外括号的调整代码:

AND USERDATA.Authority IN(1, 2) ) as MannerPoint
于 2013-09-09T10:36:42.573 回答