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

每类试卷得分前3名

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

select
    *
from
    (
        select
            tag as tid,
            uid,
            rank() over (
                partition by
                    tag
                order by
                    max(score) desc,
                    min(score) desc,
                    uid desc
            ) as ranking
            
        from
            exam_record
            join examination_info using (exam_id)
        group by
            tag,
            uid
    ) t
where
    t.ranking <= 3

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务