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

获得积分最多的人(三)

https://www.nowcoder.com/practice/d2b7e2a305a7499fb310dc82a43820e8

select d.user_id,user.name,d.new
from (
    select c.user_id,c.new
    from (
        select *,rank() over(order by b.new desc) as 'rk'
        from (
            select a.user_id,sum(a.new) as 'new'
            from (
                select *,
                    case when type = 'reduce' 
                    then -grade_num 
                    else grade_num 
                    end as 'new'
                from grade_info
                )a
            group by a.user_id)b)c
    where c.rk = 1
    order by c.user_id)d
left join user
on d.user_id = user.id

全部评论

相关推荐

11-18 15:57
门头沟学院 Java
最终归宿是测开:这个重邮的大佬在重邮很有名的,他就喜欢打92的脸,越有人质疑他,他越觉得爽😂
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务