题解 | #注册当天就完成了试卷的名单第三页#

注册当天就完成了试卷的名单第三页

https://www.nowcoder.com/practice/718d36d2667b48faa2168b6c1521816a

select er.uid
        ,ui.level
        ,ui.register_time
        /*,max(er.score) over(partition by er.uid) AS max_score*/
        ,max(er.score) AS max_score
from exam_record er
inner join user_info ui on er.uid = ui.uid
inner join examination_info ei on er.exam_id = ei.exam_id
where ei.tag = '算法' and ui.job = '算法' and date(er.submit_time) = date(ui.register_time)
group by er.uid
        ,ui.level
        ,ui.register_time
order by max_score desc
limit 6,3

1、limit 6,3表示跳过前面6行开始输出,总共输出3行。与limit 3 offset 6一样

2、函数max(score)得到符合条件的uid所有考试中的最高分

3、max(er.score) over(partition by er.uid) AS max_score开窗函数是在where之后执行的,所以如果用该函数,得到的只是算法类试卷的最高分。如果题目要算的是算法类试卷的最高分,那么用开窗函数即可,也不需要group by

全部评论

相关推荐

菜菜狗🐶:双非之光
找工作,你会甘心进小厂还...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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