mysql根据成绩排名次

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_31338557/article/details/79277047
  • (1,2,2,4 , 5)
select t.score,(select count(s.score)+1 from score s where s.score>t.score) rank from score t order by t.score desc;
  • (1,2,2,3 , 3)
select t.score,(select count(s.score)+1 from (select s.score,count(s.score) from score s group by score order by score desc) s where s.score>t.score) rank from score t order by t.score desc;
展开阅读全文

没有更多推荐了,返回首页