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

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

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

注意:相差时长大于等于限定时长的一半

with t as 
(select t.exam_id,
        TIMESTAMPDIFF(MINUTE,start_time,submit_time) as time_gap,
        row_number()over(partition by exam_id order by TIMESTAMPDIFF(MINUTE,start_time,submit_time) desc) as rn1,
        row_number()over(partition by exam_id order by TIMESTAMPDIFF(MINUTE,start_time,submit_time)) as rn2
FROM examination_info t
join exam_record t1 on t.exam_id = t1.exam_id
where submit_time is not null
)
select t1.exam_id,duration,release_time
from examination_info t1
join 
(select exam_id,sum(if(rn1=2,time_gap,0))-sum(if(rn2=2,time_gap,0)) as total_time_gap
from t
group by exam_id) t2
on t1.exam_id = t2.exam_id
where total_time_gap>=duration/2
order by exam_id desc
全部评论

相关推荐

牛客44320985...:你的当务之急是把这个糖的要死的沟槽ide主题改了
点赞 评论 收藏
分享
小浪_Coding:1. 个人技能排版太乱, 写的技术栈太浅了, 跟测试,自动化相关的太少; 2. 项目开发类的太简单没有亮点, 算法类的项目建议只放一个,最好有自动化,CI/CD, pipline的项目, 需要更换; 3.整体排版需要优化, SOOB打招呼都需要注意等.
我的简历长这样
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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