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

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

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

select 
        exam_id,duration,release_time
from
                    (
                        select a.exam_id,a.duration,a.release_time,b.submit_time,
                        timestampdiff(minute,b.start_time,b.submit_time) as diff,
                        row_number() over (partition by a.exam_id order by timestampdiff(minute,b.start_time,b.submit_time) asc) as ranking1,
                        row_number() over (partition by a.exam_id order by timestampdiff(minute,b.start_time,b.submit_time) desc) as ranking2
                        from examination_info a,exam_record b
                        where a.exam_id=b.exam_id and
                        b.submit_time is not NULL
                    ) t1
    group by exam_id
having SUM(
    case 
        when ranking1=2 then -diff
        when ranking2=2 then diff
        else 0
        end )*2 >=duration
ORDER BY exam_id DESC
;

全部评论

相关推荐

不愿透露姓名的神秘牛友
01-10 16:40
点赞 评论 收藏
分享
01-29 15:45
已编辑
华中科技大学 前端工程师
COLORSN:可以试一下,小厂看技术栈是不是很落后,如果太拉胯就别去,个人认为有实习氛围比你自己琢磨要高效不少,然后就是小厂其实也有可能会问的很难,这都比较难说,还是看自己项目含金量够不够,寒假还能不能推进学习再选择,毕竟去实习过年就10天假了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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