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

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

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

升序和降序各给数据算一次排序。 自连接,使用两种顺序为2的做题时间相减 ID降序。

	with a as((
	select e1.exam_id,e1.release_time,
	timestampdiff(minute,start_time,submit_time) diff,
	dense_rank()over(partition by exam_id order by  timestampdiff(second,start_time,submit_time)desc) diff1,
	dense_rank()over(partition by exam_id order by  timestampdiff(second,start_time,submit_time)asc) diff2,
	duration  from examination_info e1 
	left join exam_record e2
	on e1.exam_id=e2.exam_id ))
    select distinct a1.exam_id,a1.duration,a1.release_time from a a1
    left join a a2
    on a1.exam_id =a2.exam_id
    and a1.diff1=2 
    and a2.diff2=2
    where a1.diff-a2.diff >a1.duration/2
    order by exam_id desc
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 14:35
点赞 评论 收藏
分享
05-26 10:24
门头沟学院 Java
qq乃乃好喝到咩噗茶:其实是对的,线上面试容易被人当野怪刷了
找工作时遇到的神仙HR
点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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