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

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

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

# 1.按照exam_id分组计算用时最多和用时最少
# 2.排除用时最多和用时最少后,再分组,再计算最慢-最快(用时最多-用时最少)
# 3.试卷时长化成秒,用时也用秒表示
# 最慢-最快(用时最多-用时最少)>duration*60/2=duration*30
select exam_id,duration,release_time
from exam_record
left join 
(select exam_id
,max(timestampdiff(second,start_time,submit_time)) as maxtp
,min(timestampdiff(second,start_time,submit_time)) as mintp
,duration,release_time
from exam_record
left join examination_info using(exam_id)
where submit_time is not null
group by exam_id) as tt using(exam_id)
where submit_time is not null
and timestampdiff(second,start_time,submit_time) not in (tt.maxtp,tt.mintp)
group by exam_id
having (max(timestampdiff(second,start_time,submit_time))
-min(timestampdiff(second,start_time,submit_time)))>duration*30
order by exam_id desc

全部评论

相关推荐

喜欢走神的孤勇者练习时长两年半:池是池,发是发,我曾池,我现黑
点赞 评论 收藏
分享
11-24 00:11
已编辑
广东工业大学 算法工程师
避雷深圳  yidao,试用期 6 个月。好嘛,试用期还没结束,就直接告诉你尽快找下一家吧,我谢谢您嘞
牛客75408465号:笑死,直属领导和 hr 口径都没统一,各自说了一些离谱的被裁理由,你们能不能认真一点呀,哈哈哈哈哈😅😅😅
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务