我想在几轮之后展示得分最高的球员。 这是表格:
PlayerID Round number of score
1 1 4
2 1 5
3 1 8
1 2 3
2 2 10
3 2 7
预期产出
PlayerID number of score
2 15
3 15
我试过这段代码,但这里有错误。如何显示输出?
SELECT playerID , MAX(SUM(numberOfGoals)) FROM Game;
答案 0 :(得分:2)
尝试:
SELECT playerID, SUM(numberOfGoals) AS numberOfGoals
FROM Game
GROUP BY playerID
HAVING SUM(numberOfGoals) IN (SELECT MAX(goals) FROM (SELECT SUM(numberOfGoals) goals
FROM Game GROUP BY playerID) t)
答案 1 :(得分:1)
SELECT playerId, Sum(numberofscore)
FROM Game
Group By PlayerId
Order By Sum(numberofscore) Desc