题解 | #最差是第几名(一)#
最差是第几名(一)
http://www.nowcoder.com/practice/ae5e8273e73b4413823b676081bd355c
知识点
- 使用窗函数对grade进行分组然后,使用sum() over (order by ) 开窗函数,sum(a) over (order by b) 的含义是:按照b列排序,将a依次相加
代码
select grade, sum(number) over(order by grade) as t_rank
from class_grade
order by grade