题解 | #每类试卷得分前3名#

每类试卷得分前3名

https://www.nowcoder.com/practice/255aa1863fe14aa88694c09ebbc1dbca

with temp as(
select
    a.uid,
    b.tag as tid,
    max(score) as max,
    min(score) as min
from exam_record as a 
left join examination_info as b 
on a.exam_id = b.exam_id
group by 
    a.uid,
    b.tag
)

select 
    tid,
    uid,
    flag as ranking
from
(select 
    tid,
    uid,
    rank() over (partition by tid order by max desc, min desc, uid desc) as flag
from temp
) as a 
where flag <= 3

全部评论

相关推荐

华为北京什么时候签约,哪位老哥来个准信
投递华为北京研究所等公司10个岗位 >
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务