乐扣原题:https://leetcode.cn/problems/rank-scores/
题解:
不用函数
select
s1.Score,
count(distinct(s2.score)) `rank`
from
Scores s1,Scores s2
where
s1.score<=s2.score
group by s1.Id
order by `rank`
使用函数
select
Score score,
dense_rank() over (order by score desc ) `rank`
from
Scores