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

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

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-28 17:58
门头沟学院 Java
美团 JAVA开发 n×15.5
牛客786276759号:百度现在晋升很难的 而且云这块的业务没美团好 你看百度股价都跌成啥样了
点赞 评论 收藏
分享
评论
1
收藏
分享
牛客网
牛客企业服务