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

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

相关文章:

  • 2022-01-09
  • 2021-11-18
  • 2021-06-12
  • 2021-05-26
  • 2022-12-23
  • 2021-09-07
  • 2022-01-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-09
  • 2022-01-27
  • 2022-12-23
  • 2021-07-20
  • 2022-02-10
  • 2021-11-29
相关资源
相似解决方案