我的 MySQL 查询如何给出所有游戏的排名只给出每个玩家顶级游戏的排名?

How can my MySQL query giving the rank of all games just give the rank of each players top game?

SELECT 
1+(SELECT count(*) from games a WHERE a.score > g.score) as rank,
score, p.leaderboard_initials, p.operating_system
FROM games g
inner join players p on (p.google_id = g.google_id)
ORDER BY score DESC
LIMIT 0, 100;

Returns 一个排行榜,包含玩家的每场比赛。

我需要 return 排行榜,其中仅列出每位玩家的最佳得分游戏。因此 44rhh 仍将排在首位,其次是 DMC,但 BMO 将排在第三位。

我知道解决方案应该很简单,但我就是想不出该怎么做!

您可以 select 最高分数组 leaderboard_initials

您可以 select 最高分数组 leaderboard_initials

set @rank=0;
select (@rank:=@rank+1) rank , leaderboard_initials, max(score)  max_score  
from  (
    SELECT 
    1+(SELECT count(*) 
    from games a WHERE a.score > g.score) as rank,
    score, p.leaderboard_initials, p.operating_system
    FROM games g
    inner join players p on (p.google_id = g.google_id)
    ORDER BY score DESC
    LIMIT 0, 100;
) t  
group by leaderboard_initials 
order by max_score DESC