with t1 as ( select exam_id, NTH_VALUE(timestampdiff(second,start_time,submit_time),2) over(PARTITION BY exam_id order by timestampdiff(second,start_time,submit_time) asc) min_2, NTH_VALUE(timestampdiff(second,start_time,submit_time),2) over(PARTITION BY exam_id order by ...