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

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

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
全部评论

相关推荐

04-25 18:13
五邑大学 Java
后来123321:大二两段实习太厉害了,我现在大二连面试都没有
点赞 评论 收藏
分享
待现的未见之事:起码第一句要把自己的优势说出来吧。比如什么xx本27届学生,随时到岗....
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务