SQL分组有序记录集

时间:2014-11-03 23:04:57

标签: mysql

我从mySQL数据库中提取列表以获得高分表;

SELECT playerID, score FROM leaderboards ORDER BY score DESC

如果他们提交了多个分数,那么同一个玩家ID通常会多次出现。 有没有办法编辑我的查询只显示用户得分最高并忽略他的跟随?

2 个答案:

答案 0 :(得分:0)

SELECT playerID, max(score) as max_score 
FROM leaderboards 
GROUP BY playerID
ORDER BY max_score DESC

答案 1 :(得分:0)

所以你想获得一个得分最高的球员名单?

SELECT playerID, MAX(score) as max_score 
FROM leaderboards 
GROUP BY playerID 
ORDER BY max_score DESC