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

最差是第几名(二)

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


# 写的太麻烦了!!!嘿嘿


select
a.grade
from(
select
a.grade
,lag(a.en,1,0) over(order by a.en)+1 as st
,a.en
,a.qian
,a.hou
from(
select
a.grade
,sum(a.number) over(order by a.grade asc) as en
,(select round(if(a.sum_number%2=0,a.sum_number/2,(a.sum_number+1)/2),0) from (select sum(a.number) as sum_number from class_grade a) a) as qian
,(select round(if(a.sum_number%2=0,a.sum_number/2+1,(a.sum_number+1)/2),0) from (select sum(a.number) as sum_number from class_grade a) a) as hou
from class_grade a
) a
) a
where (a.qian>=a.st and a.qian<=a.en)
or (a.hou>=a.st and a.hou<=a.en)
order by a.grade
;


全部评论

相关推荐

ArisRobert:统一解释一下,第4点的意思是,公司按需通知员工,没被通知到的员工是没法去上班的,所以只要没被通知到,就自动离职。就是一种比较抽象的裁员。
点赞 评论 收藏
分享
安静的垂耳兔在泡澡:ks已经第八次投递了,它起码挂了还让你再投,不错了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务