题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数
https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8
SELECT
up.university university,
qd.difficult_level difficult_level,
COUNT(up.device_id)/COUNT(DISTINCT up.device_id) avg_answer_cnt --经过大学+设备id分组后,得到组下的所有已回答设备,求平均每个设备的回答数
FROM
user_profile up
INNER JOIN
question_practice_detail qpd using(device_id)
INNER JOIN
question_detail qd using(question_id)
GROUP BY up.university,qd.difficult_level;