这题有个大坑,他没说level_cnt一样的情况下level怎么排序,实际上应该按level_cnt和level降序排列。

select level, count(distinct uid) as level_cnt from 
user_info join exam_record
using(uid)
where score > 80 and exam_id = 9001
group by level
order by level_cnt desc, level desc