题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数
http://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8
SELECT university,difficult_level,count(qpd.result)/count(DISTINCT u.device_id) as avg_answer_cnt from user_profile as u join question_practice_detail as qpd on u.device_id = qpd.device_id join question_detail as qd on qpd.question_id = qd.question_id group by u.university,qd.difficult_level
#第一个点:join格式-- a join b on XXXXXXX join c on XXXXXXX #第二个点:distinct 用来唯一确定元素,做均值的时候经常会用到 #第三个点:看清楚要求的结果 错误的写成了sum(u.answer_cnt)其实这是回帖数