mysql分数排名,分数相同名次相同

  |   0 评论   |   0 浏览

比如给定一张scores

idscore
133.2
235.4
335.4
436.4
537.3
637.3
738.4

要求排序后输出

名次score
138.4
237.3
237.3
336.4
435.4
435.4
533.2
select  s.score , 
(select count(distinct m.score)+1 from scores m where m.score> s.score)
from scores s order by s.score desc

标题:mysql分数排名,分数相同名次相同
作者:码农路上
地址:http://wujingjian.club/articles/2021/06/07/1623056584337.html