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

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

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


with table1 as(
    select exam_id,
    duration,
    timestampdiff(minute,start_time,submit_time) as time,release_time
    from exam_record left join examination_info using(exam_id)
    where submit_time is not null
),
table2 as (
    select exam_id,time,
    row_number() over(partition by exam_id order by time desc) as desc_time,
    row_number() over(partition by exam_id order by time) as asc_time,
    duration , release_time
    from table1
),
table3 as (
select exam_id,duration,release_time, 
sum(case when desc_time = 2 then time 
         when asc_time = 2 then -time
         else 0 
         end) as sum_time
from table2
group by exam_id,duration,release_time
having sum_time >= duration*0.5
order by exam_id desc
)
select exam_id,duration,release_time
from table3

全部评论

相关推荐

03-05 17:03
已编辑
浙江工商大学 C++
陈好好wy:整体看下来有点空空的感觉,可以把每一段项目经历都再完善一下,然后用小标题的形式写个两到三条,目前看有点太简单了,不太能看出具体在这个项目里做了什么工作。还是要尽量把自己做的工作以量化的形式体现在简历上呢。
双非本科求职如何逆袭
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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