select
grade,
sum(number) over(order by grade rows between unbounded preceding and current row) as t_rank
from
class_grade
order by
grade