SELECT uid, round(avg(score), 0)as avg_score, round(avg(took), 1)as avg_time_took from ( select exam_record.uid, exam_record.exam_id, if(submit_time is null, examination_info.duration, TIMESTAMPDIFF(MINUTE, start_time, submit_time)) as took, if(score is null, 0, score) as score from exam_record join...