SELECT ui.uid, SUM(IF(score IS NULL AND start_time IS NOT NULL,1,0)) incomplete_cnt, ROUND(AVG(IF(score IS NULL AND start_time IS NOT NULL,1,0)),3) incomplete_rate from user_info ui left join exam_record er using(uid) where if((SELECT ui.uid FROM user_info as ui LEFT JOIN exam_record as er ON ui.uid = er.uid WHERE level = '0' GROUP BY ui.uid HAVING SUM(IF(score IS NULL AND start_time IS NOT NULL,1,0))>2) IS NOT NULL, level = '0', start_time IS NOT NULL) group by ui.uid order by incomplete_rate