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

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

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

Select exam_id, duration, release_time
from examination_info
where exam_id in (
    Select exam_id
    from(
    Select exam_id, timediff(min(td),max(td)) as diff, duration
    from (
    Select exam_id , td, duration
    from (
    Select er.exam_id, uid, timediff(start_time, submit_time) as td, duration, 
    row_number() over(partition by er.exam_id order by timediff(start_time, submit_time) DESC ) as subtimeDESC_rank, row_number() over(partition by er.exam_id order by timediff(start_time, submit_time) ASC ) as subtimeASC_rank
    from exam_record er left join examination_info ei on er.exam_id = ei.exam_id
    where submit_time is not null 
    ) t1
    where  subtimeDESC_rank = 2 or subtimeASC_rank = 2 ) t2
    group by exam_id
    having minute(diff) >= duration/2 ) t3
)
    order by exam_id desc

全部评论

相关推荐

01-21 12:25
产品经理
蝴蝶飞出了潜水钟丿:是不是在暗示男女待遇不一样xxn要来冲你了
点赞 评论 收藏
分享
Cassifa:发的字比你都多的一律视为骗子或者想白嫖压榨实习生的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务