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

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

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

最开始有这个想法,但不知道是否有这个函数,便看了一下题解里面有这样一个函数nth_values()over()便引起了我的兴趣。就去网上查阅了以下,就是我想到做题的最优解。便自己试了一下,居然成功了,哈哈哈

select distinct ei.exam_id,
    ei.duration,
    ei.release_time
from examination_info as ei
left join
(select exam_id ,
    nth_value(timestampdiff(minute, start_time, submit_time), 2) over (partition by exam_id order by timestampdiff(minute, start_time, submit_time) desc) as R,
    nth_value(timestampdiff(minute, start_time, submit_time), 2) over (partition by exam_id order by timestampdiff(minute, start_time, submit_time) asc) as r1
from exam_record ) as a
on ei.exam_id = a.exam_id
where (a.R - a.r1) > (ei.duration / 2)
order by ei.exam_id desc;
全部评论

相关推荐

07-23 12:04
门头沟学院 Java
现在是很缺人吗
码农索隆:缺分母,不缺分子,这样好作为炫耀的资本
点赞 评论 收藏
分享
07-25 13:42
门头沟学院 Java
安锋:看看老板的腿
点赞 评论 收藏
分享
机械打工仔:有说的你怀疑一下就行了,直接问也太实诚了
点赞 评论 收藏
分享
熬夜冠军🏆:和你情况差不多,你这个HR算敞亮了,直白告诉你了,不浪费你时间,我的那个还跟我说没法说,只能等。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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