题解 | #获得积分最多的人(二)#
获得积分最多的人(二)
http://www.nowcoder.com/practice/b6248d075d2d4213948b2e768080dc92
不用join
select user_id,name,grade_sum
from
(select * ,dense_rank() over (order by grade_sum desc) as rank1 from
(select user_id,(select name from user where grade.user_id=user.id) name,
sum(grade_num) grade_sum
from grade_info grade
group by user_id) a) b
where rank1<=1