题目要求写一个sql查询来实现分数排名,但排名不能有间隔
select a.Score ,(select count(distinct Score) from Scores b where b.Score>=a.Score)
as `Rank`
from Scores a order by Score desc
思路
对于a表中的成绩,计算出b表有多少个不重复的成绩大于a表的成绩,计算出来的数据就是a表的排名
题目要求写一个sql查询来实现分数排名,但排名不能有间隔
select a.Score ,(select count(distinct Score) from Scores b where b.Score>=a.Score)
as `Rank`
from Scores a order by Score desc
思路
对于a表中的成绩,计算出b表有多少个不重复的成绩大于a表的成绩,计算出来的数据就是a表的排名