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

最差是第几名(二)

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
;


全部评论

相关推荐

11-09 17:30
门头沟学院 Java
TYUT太摆金星:我也是,好几个华为的社招找我了
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务