1.row_number select exam_id, duration, release_time from ( SELECT er.exam_id, uid, duration, release_time, TIMESTAMPDIFF(MINUTE, start_time, submit_time) as spend_time, ROW_NUMBER() over( partition by exam_id order by TIMESTAMPDIFF(MINUTE, start_time, submit_time) desc ) as rank1, ROW_NUMBER() over(...