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

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

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

全部评论

相关推荐

强大的马里奥:不太可能,我校计算机硕士就业率99%
点赞 评论 收藏
分享
05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
测试糕手手:社会第一课,随便吹牛逼,直接说四个月,别老实。老实人只会被欺负
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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