select t.level,count(distinct t.uid) as level_cnt
from (
    select t1.uid,t1.level
    from user_info t1
    join exam_record t2 on t1.uid = t2.uid
    join examination_info t3 on t2.exam_id = t3.exam_id 
    where t3.tag = 'SQL' and t2.score > 80
        ) t
group by t.level
order by level_cnt desc,level desc