题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数
https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8
方法1:三表左外连接
select c.university, b.difficult_level, count(a.device_id) / count(distinct a.device_id) as avg_answer_cnt from question_practice_detail a left join question_detail b on a.question_id = b.question_id left join user_profile c on a.device_id = c.device_id group by c.university, b.difficult_level
方法2:三表内连接
select c.university, b.difficult_level, count(a.device_id) / count(distinct a.device_id) as avg_answer_cnt from question_practice_detail a, question_detail b, user_profile c where a.question_id = b.question_id and a.device_id = c.device_id group by c.university, b.difficult_level