题解 | #出现三次以上相同积分的情况#

考试分数(五)

http://www.nowcoder.com/practice/b626ff9e2ad04789954c2132c74c0512

窗口函数 永远滴神!

select  t1.id,
    t1.job, score,
    t_rank from ( select  id, job, score, dense_rank() over (partition by job order by score desc ) t_rank from grade
)t1 inner join ( select  job, round(count(id)/2) start, round((count(id)+1)/2) end  from grade group by job )t2 on t1.t_rank in (t2.start,t2.end) and t1.job = t2.job order by t1.id;

全部评论

相关推荐

投递美团等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务