题解 | #获得积分最多的人(二)#
获得积分最多的人(二)
https://www.nowcoder.com/practice/b6248d075d2d4213948b2e768080dc92
select id,name,sum_grade from( select *,dense_rank()over(order by sum_grade desc) as rn from( select *,sum(gi.grade_num)over(partition by gi.user_id order by gi.grade_num) as sum_grade from user u join grade_info gi on u.id=gi.user_id) t1) t2 where rn =1 order by id
由于我上一题也是用这样的解法,直接copy过来就可以了
#MySQL#