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

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

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

with t1 as (select
  exam_id,
  timestampdiff(minute,start_time ,submit_time)  as x1,         
  row_number() over (partition by exam_id  order by timestampdiff(minute,start_time ,submit_time) desc)
  as second_slow,
  row_number() over (partition by exam_id  order by timestampdiff(minute,start_time ,submit_time) )
  as second_qucik,
  duration,
  release_time        
from exam_record
join examination_info
using(exam_id)
where score is not null)

select exam_id,t2.duration,t2.release_time
from(
        select *
        from t1
        where second_slow=2 ) as t2
left join (
        select *
        from t1
        where second_qucik=2 ) as t3
using(exam_id)

where  (t2.x1-t3.x1)>=t2.duration/2
group by exam_id
order by exam_id desc
全部评论

相关推荐

02-11 17:51
腾讯_TEG_技术
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务