SELECT uid , ROUND(avg(score),0) AS avg_score, ROUND(avg(yongshi),1) AS avg_time_took FROM (SELECT uid, IF(submit_time IS NULL,duration,timestampdiff(minute,start_time,submit_time)) yongshi, IF(score IS NULL,0,score) as score FROM exam_record er LEFT JOIN examination_info ei ...