LeetCode数据库178题

对成绩进行排序,名次是连续的的,可出现同名次

sql语句分析理解:
**1.**复制一张表得到b,去,a表中的一个分数进行与b的全部分数进行比较,找出b中大于等于的分数个数,然后去除重复的分数,统计剩余的个数:
(select count(distinct b.Score) from Scores b where b.Score >= a.Score) as “Rank”
LeetCode数据库178题
**2.**按分数的降序排列,选择Scorce和统计的排名打印出来:
select a.Score as Score,
(select count(distinct b.Score) from Scores b where b.Score >= a.Score) as “Rank”

**3.**最终的结题程序:
select a.Score as Score,
(select count(distinct b.Score) from Scores b where b.Score >= a.Score) as “Rank”
from Scores a
order by a.Score DESC