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

考试分数(五)

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

select
    id,
    job,
    score,
    t_rank
from (
    select
        id,
        job,
        score,
        count(score) over (partition by job) as total,
        row_number() over(partition by job order by score desc) as t_rank
    from grade
) as g1
where 
(
    case when total % 2 = 0 then t_rank = total/2 or t_rank = total/2 + 1
    else t_rank = CEILING(total/2)
    end )
order by id

全部评论

相关推荐

点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-16 18:05
点赞 评论 收藏
分享
机械打工仔:有说的你怀疑一下就行了,直接问也太实诚了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
07-15 18:09
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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