题解 | 获得积分最多的人(一)

获得积分最多的人(一)

https://www.nowcoder.com/practice/1bfe3870034e4efeb4b4aa6711316c3b

select name, grade_num
from (
select t2.name, t1.grade_num, dense_rank() over(order by t1.grade_num desc) as rk
from (
    select user_id, sum(grade_num) as grade_num
    from grade_info
    group by 1
) t1
join user t2 on t1.user_id = t2.id
) A 
where rk = 1

如果不止一个第一名,可以这样

全部评论

相关推荐

轻絵梨花泪沾衣:南泵,大少爷驾到通通闪开
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务