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

考试分数(五)

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

select
    id,
    a.job,
    score,
    t_rank
from
    (select 
        id,
        job,
        score,
        row_number() over(partition by job order by score desc) as t_rank
    from 
        grade ) a
left join 
    (
    select 
        job,
        floor(if(count(*)%2=0, count(*)/2, (count(*)+1)/2)) as start,
        floor(if(count(*)%2=0, count(*)/2+1, (count(*)+1)/2)) as end
    from 
        grade 
    group by
        job
    order by
        job
    ) b
on a.job = b.job and a.t_rank >= b.start and a.t_rank <= b.end
where b.job is not null
order by id

全部评论

相关推荐

10-10 11:38
已编辑
湖南理工大学 Java
小浪_Coding:多沟通叭, 公式简历+学历一般的话难找
点赞 评论 收藏
分享
在看牛客的社畜很积极:身高体重那一行信息去掉,学校那一行的信息放上面,找半天都没找到你是哪个学校什么专业的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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