题解 | #第二快/慢用时之差大于试卷时长一半的试卷#
第二快/慢用时之差大于试卷时长一半的试卷
https://www.nowcoder.com/practice/b1e2864271c14b63b0df9fc08b559166
with slow_2nd as ( select exam_id, slow_use from ( select exam_id, timestampdiff(second, start_time, submit_time) slow_use, row_number()over(partition by exam_id order by timestampdiff(second, start_time, submit_time) desc) slow_rank from exam_record where submit_time is not null ) a where slow_rank = 2 ), fast_2nd as ( select exam_id, fast_use from ( select exam_id, timestampdiff(second, start_time, submit_time) fast_use, row_number()over(partition by exam_id order by timestampdiff(second, start_time, submit_time)) fast_rank from exam_record where submit_time is not null ) b where fast_rank = 2 ) select exam_id, duration, release_time from examination_info left join slow_2nd using (exam_id) left join fast_2nd using (exam_id) where (slow_use - fast_use) * 2 > duration * 60 order by exam_id desc
注意:比较时间的时候,一定要注意精确度,应该按题目中给出的最小精确度来进行比较(如果没有特别说明的话)
本题应该精确到秒