题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数
https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8
select university, difficult_level, count(qpd.question_id)/count(distinct qpd.device_id) as avg_answer_cnt from question_practice_detail as qpd join user_profile up on qpd.device_id=up.device_id join question_detail qd on qpd.question_id = qd.question_id group by university,difficult_level;
题目很长,但描述得很详细,所以逻辑并不难,不要被吓倒。
count()计数,distinct去重,三表连接,与两表连接是类似的,只不过多加一句join...on...