题解 | #作答试卷得分大于过80的人的用户等级分布#
作答试卷得分大于过80的人的用户等级分布
https://www.nowcoder.com/practice/5bc77e3a3c374ad6a92798f0ead4c744
select level,
count(ui.uid) as level_cnt
from exam_record as er join examination_info as ei
on er.exam_id = ei.exam_id
join user_info ui
on er.uid = ui.uid
where score > 80 and tag = 'SQL'
group by level
order by level_cnt desc,level desc
#什么时候连表,什么时候子查询,真是搞不清楚。好像连表的时候带group by的时候更多,子查询带where的时候更多
自己的假设,需要分组的时候多用连表,不需的时候多用子查询。有待验证
