题解 | #最差是第几名(二)#

最差是第几名(二)

https://www.nowcoder.com/practice/165d88474d434597bcd2af8bf72b24f1

破题,不看提示硬控我五个小时,最后参考区间法做出

with median as (
       select grade,number,he,add_up,med,lag(add_up)over(order by grade) la
       from (select grade,number,sum(number)over() he,sum(number)over(order by grade) add_up,sum(number)over()/2 med
        from class_grade) t1
    )
select grade
from median 
where med between la and add_up

全部评论

相关推荐

CrazyBucket:我今天下午也做梦在招聘会上面试一家小厂,给自己气笑了
点赞 评论 收藏
分享
1 收藏 评论
分享
牛客网
牛客企业服务