一、明确需求:
作答SQL类别的试卷得分>80的用户的等级分布
二、问题分解
- 1、筛选符合条件的用户
- 2、对输出进行调整
三、代码实现
select level,count(distinct t1.uid) level_cnt
from
(
select distinct uid
from exam_record
where score > 80 and exam_id in (select distinct exam_id from examination_info where tag = 'SQL')
) t1
left join user_info t2
on t1.uid = t2.uid
group by t2.level
order by level_cnt desc,level desc