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

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

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

select distinct a.exam_id,b.duration,b.release_time from(
select exam_id,
    timestampdiff(minute,start_time,submit_time) as t,
dense_rank() over(partition by exam_id order by 
timestampdiff(minute,start_time,submit_time) asc) t_a,
dense_rank() over(partition by exam_id order by 
timestampdiff(minute,start_time,submit_time) desc) t_d
from exam_record where submit_time is not null )a,examination_info b 
where a.exam_id=b.exam_id
and (a.t_d=2 or a.t_a=2)
group by 1,2,3
having max(a.t)-min(a.t)>=avg(b.duration)/2
order by a.exam_id desc




全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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