题解 | 子查询+左连接

考试分数(五)

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

select g.*
from 
(select *,dense_rank() over(partition by job order by score desc) as t_rank
from grade) g
left join  
(select job,floor((count(*)+1)/2) as start,floor((count(*)+2)/2) as end
 from grade group by job ) r
 on g.job=r.job
 where g.t_rank=r.start or g.t_rank=r.end
 order by g.id

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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