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

考试分数(五)

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

感觉这种题很怪

select 
    id,job,score,rk
from 
(
    select 
        id,job,score,rk,case when top mod 2 = 0 then if(rk=round(top/2) or rk=(round(top/2) + 1) ,1,0) else if(rk=(floor(top/2)+1),1,0) end as flag
    from 
    (
        select 
            id,job,score,rk,max(rk) over(partition by job) as top
        from 
        (
            select 
                id,job,score,dense_rank() over(partition by job order by score desc) as rk
            from grade
        ) t1 
    ) t2 
) t3 where flag = 1
order by id

全部评论

相关推荐

点赞 评论 收藏
分享
有趣的牛油果开挂了:最近这个阶段收到些杂七杂八的短信是真的烦
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务