LeetCode-SQL-178. 分数排名

https://leetcode-cn.com/problems/rank-scores/

SELECT Score, Rank FROM
(SELECT Score,
@cur := IF(@preScore = Score, @cur+0,@cur:=@cur+1) AS Rank,
@preScore := Score
FROM Scores, (
SELECT @cur :=0, @preScore := null
) help
ORDER BY Score DESC) s
发布了137 篇原创文章 · 获赞 2 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/m0_37302219/article/details/104947270
今日推荐