gpt4 book ai didi

mysql - mySQL中如何显示最高分

转载 作者:太空宇宙 更新时间:2023-11-03 11:34:33 25 4
gpt4 key购买 nike

我想在几轮之后显示得分最高的玩家。这是表格:

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)

Results

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com