思路:最差排名 = 比自己成绩等级高的number总数 + 自己成绩等级number的个数

技巧:单表如果需要有排序,那么自连接一定可以解决

select t1.grade, sum(t2.number) as t_rank
from class_grade as t1
join class_grade as t2
on t1.grade >= t2.grade
group by t1.grade
order by t1.grade