我想在几个回合后展示得分最高的球员。
表格如下:

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;

最佳答案

尝试这个:

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)


mysql - 如何在MySQL中显示最高分数-LMLPHP

关于mysql - 如何在MySQL中显示最高分数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46928907/

10-11 02:49