题解 | #第二快/慢用时之差大于试卷时长一半的试卷#

第二快/慢用时之差大于试卷时长一半的试卷

https://www.nowcoder.com/practice/b1e2864271c14b63b0df9fc08b559166

select distinct exam_id,duration,release_time
from (select 
    t1.exam_id,
    t2.duration,
    t2.release_time,
    timestampdiff(minute,start_time,submit_time) as costtime,
    row_number() over(partition by t1.exam_id order by timestampdiff(minute,start_time,submit_time) asc) as rank1,
    row_number() over(partition by t1.exam_id order by timestampdiff(minute,start_time,submit_time) desc) as rank2
    from exam_record t1
    left join examination_info t2
    using(exam_id)
    where t1.submit_time is not null) t
group by exam_id
having sum(case when rank1=2 then -costtime when rank2=2 then costtime else 0 end)*2 >= duration
order by exam_id desc

全部评论

相关推荐

昨天 15:12
门头沟学院 Java
别人在上班,我就在工位上看看视频啥的,这正常吗?
程序员小白条:实习就是摸鱼,只是公司指标,把你进来了,可能那时候客户很多,但等你进来的时候,已经是淡季了,根本没多少需求,或者说根本不适合实习生去完成,因此你就每天干坐着就行,可能1,2个月都没需求
实习生的蛐蛐区
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
合不合适,我自己说了才算
码农索隆:hr:“真执着啊,来我公司当法人吧”
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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