select exam_id, count(distinct uid) as uv, round(sum(score) / count(uid), 1) as avg_score from exam_record join examination_info using (exam_id) join user_info using (uid) where tag = 'SQL' and level > 5 and date(submit_time) = date(release_time) group by exam_id, date(release_time) order by uv desc, avg_score