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

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

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
注意:比较时间的时候,一定要注意精确度,应该按题目中给出的最小精确度来进行比较(如果没有特别说明的话)
本题应该精确到秒
全部评论

相关推荐

06-13 15:45
辽宁大学 golang
咱就是说 你不主动 我也不会主动下一步hhh,急死了
恶龙战士:不建议把这种帖子发到牛客上,建议去小红书发
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 20:55
因为业务不是喜欢的,所以就没去,现在实习工作也有很多dirtywork,很后悔,怎么能舔回这个offer啊
flmz_Kk:试一试跟hr舔回来,不过保不齐米的活也有很多dirtywork,只能说不要美化自己没走过的路
投递小米集团等公司6个岗位 >
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务