select distinct exam_id, duration, release_time from ( select i.exam_id, duration, release_time, timestampdiff(second,start_time,submit_time) as time_cost, nth_value(timestampdiff(second,start_time,submit_time),2) over( partition by i.exam_id order by timestampdiff(second,start_time,submit_time) asc...