题解 | #每类试卷得分前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
全部评论

相关推荐

仁者伍敌:实习生要工作经验,工作要实习经验
点赞 评论 收藏
分享
nus2201602...:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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