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

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

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

select distinct exam_id,duration,release_time
from (select 
    t1.exam_id,
    t2.duration,
    t2.release_time,
    timestampdiff(minute,start_time,submit_time) as costtime,
    row_number() over(partition by t1.exam_id order by timestampdiff(minute,start_time,submit_time) asc) as rank1,
    row_number() over(partition by t1.exam_id order by timestampdiff(minute,start_time,submit_time) desc) as rank2
    from exam_record t1
    left join examination_info t2
    using(exam_id)
    where t1.submit_time is not null) t
group by exam_id
having sum(case when rank1=2 then -costtime when rank2=2 then costtime else 0 end)*2 >= duration
order by exam_id desc

全部评论

相关推荐

没有offer的小土豆:专业面试一般是分配面试官然后联系你面试 应该是还没给你分配对应面试官
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务