题解 | 考试分数(五)

------一切以实现功能为主系列
select id, job, score, rk as t_rank
from
(
    select id, job, score, rk, floor((cnt+1) /2) as start, ceiling((cnt+1)/2) as end
    from
    (
        select id, job, score, row_number() over(partition by job order by score desc) as rk, count(job) over(partition by job) as cnt
        from grade
    ) as t
) as t1
where rk=start or rk=end
order by id asc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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