有成绩表score如下
窗口函数
- rank()
SELECT *, rank() over (order by `SCORE` desc) as 'ranking' from leetcode.score;
- dense_rank()
SELECT *, dense_rank() over (order by `SCORE` desc) as 'denseRank' from leetcode.score;
leetcode178.分数排名
具体实现
select Score, dense_rank() over (order by Score desc) as `Rank` from Scores