select er.exam_id as exam_id,
count(distinct er.uid) as uv,
round(avg(score),1) as avg_score
from exam_record as er
left join examination_info using(exam_id)
left join user_info using(uid)
where level>5 and tag='SQL' and date(start_time)=date(release_time)
group by exam_id
order by uv desc,avg_score asc