题解 | #统计每个用户的平均刷题数#
统计每个用户的平均刷题数
https://www.nowcoder.com/practice/f4714f7529404679b7f8909c96299ac4
运营想要计算一些参加了答题的不同学校、不同难度的用户平均答题量,请你写SQL取出相应数据
#sql书写顺序:select···from···where···group by···having···order by···limit··· //以上语句不能颠倒
#sql执行顺序:from···where···group by···having···select···order by···limit···
select university, difficult_level, round( count(qpd.question_id) / count(distinct(qpd.device_id)), 4 ) as avg_answer_cnt from question_practice_detail as qpd left join user_profile as up on qpd.device_id = up.device_id left join question_detail as qd on qd.question_id = qpd.question_id where university = '山东大学' group by difficult_level;

