Leetcode Database 178 RankScores

https://leetcode.com/problems/rank-scores/discuss/175194/Simple-using-variables

SELECT score , @rank :=   @rank + CASE WHEN @score <> (@score := score)  THEN  1 ELSE 0 END  as Rank
from Scores, (SELECT @score := -1, @rank := 0) init
order by Score DESC;

https://leetcode.com/problems/rank-scores/discuss/187650/Simple-Dense_Rank()-solution
select score, dense_rank() over ( order by Score desc) [Rank] from scores

https://blog.csdn.net/biaobiao1217/article/details/41077417
posted @ 2018-10-30 17:12  红烧西红柿  阅读(162)  评论(0编辑  收藏  举报