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

每类试卷得分前3名

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

嵌套了两次,首先根据tag和uid分组并找出每组最大值最小值,然后根据最大值最小值以及uid使用row_number赋予排序标签,最后限制前三名

select * from
(select tag, uid, row_number() over (partition by tag order by max_grade desc, min_grade desc, uid desc) as ranking
from
(select tag, uid, max(score) as max_grade, min(score) as min_grade
from examination_info join exam_record using(exam_id)
group by tag, uid) as temp) as temp2
where ranking < 4
全部评论

相关推荐

点赞 评论 收藏
分享
11-19 18:44
已编辑
成都理工大学 Java
程序员花海:我面试过100+校招生,大厂后端面试不看ACM,竞赛经历含金量低于你有几份大厂实习 这个简历整体来看不错 可以海投
如何写一份好简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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