题解 | #牛客的课程订单分析(三)#

最差是第几名(二)

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

select grade from class_grade a4 , ( select * from (select grade as g1 from (select sum(number)as sum,round(sum(number)/2) as s,if(sum(number)%2=0,round(sum(number)/2)+1,round(sum(number)/2))as e from class_grade)as pos, ( select grade, ( select sum(number) from class_grade c1 where c1.grade<=cg.grade ) as r, ( select count(grade) from class_grade c1 where c1.grade<=cg.grade ) as c from class_grade cg group by grade order by grade ) as g where g.r>=pos.s limit 1) as a1 join (select grade as g2 from (select sum(number)as sum,round(sum(number)/2) as s,if(sum(number)%2=0,round(sum(number)/2)+1,round(sum(number)/2))as e from class_grade)as pos, ( select grade, ( select sum(number) from class_grade c1 where c1.grade<=cg.grade ) as r, ( select count(grade) from class_grade c1 where c1.grade<=cg.grade ) as c from class_grade cg group by grade order by grade ) as g where g.r>=pos.e limit 1) as a2 )as a3 where a4.grade=a3.g1 or a4.grade=a3.g2 order by grade

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-21 19:05
点赞 评论 收藏
分享
想润的芹菜人狠话不多:把其中一个老总放中间都会得罪另一个
点赞 评论 收藏
分享
爱看电影的杨桃allin春招:我感觉你在炫耀
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务