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

每类试卷得分前3名

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

with data_for_use as (
    select exam_id, tag, uid, score
    from exam_record
    left join examination_info using (exam_id)
    where score is not null
), tag_uid_score as (
    select tag, uid, max(score) mxs, min(score) mis
    from data_for_use
    group by tag, uid
)
select tag as tid, uid, ranking
from (
    select tag, uid, 
        row_number()over(partition by tag order by mxs desc, mis desc, uid desc) as ranking
    from tag_uid_score
    ) a 
where ranking <= 3

全部评论

相关推荐

06-20 17:42
东华大学 Java
凉风落木楚山秋:要是在2015,你这简历还可以月入十万,可惜现在是2025,已经跟不上版本了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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