题解 | #考试分数(四)#

考试分数(四)

http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c

思路:利用row_number() 确定排名,然后根据排名顺序确定中位数位置范围

#group by 自带排序,默认升序
select d.job,
(case mod(max(rk), 2)
when  0 then round(max(rk)/2,0) 
when  1 then round(max(rk)/2, 0)
end) as start,
(case mod(max(rk), 2)
when 0 then round(max(rk)/2,0) + 1
when 1 then round(max(rk)/2, 0)
end) as end
from (select *, (row_number() over(partition by job order by job)) as rk from grade) d group by d.job;
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务