select exam_id,count(distinct uid) as uv,round(avg(score),1) as avg_score
from exam_record
where exam_id in (select exam_id from examination_info where tag = 'SQL') 
      and uid in (select uid from user_info where level >5)
      and date(submit_time) in (select date(release_time) from examination_info where tag = 'SQL')
      and submit_time is not NULL
group by exam_id,date(submit_time)
order by uv desc,avg_score asc