题解 | #统计每个用户的平均刷题数#
统计每个用户的平均刷题数
https://www.nowcoder.com/practice/f4714f7529404679b7f8909c96299ac4
SELECT up.university, qd.difficult_level, -- qpd.question_id / up.device_id 的列信息需要加表前缀,因为是内连接,加不同表前缀(前提是该表有相应的列字段)结果是相同的 ROUND(COUNT(qpd.question_id) / COUNT(DISTINCT up.device_id), 4) AS avg_answer_cnt FROM question_practice_detail AS qpd INNER JOIN user_profile AS up ON qpd.device_id = up.device_id INNER JOIN question_detail AS qd ON qpd.question_id = qd.question_id WHERE up.university = '山东大学' GROUP BY difficult_level