题解 | #统计每个用户的平均刷题数#
统计每个用户的平均刷题数
http://www.nowcoder.com/practice/f4714f7529404679b7f8909c96299ac4
select up.university,qd.difficult_level,count(qpd.device_id)/count(distinct up.device_id) from user_profile up,question_practice_detail qpd,question_detail qd
where up.university='山东大学'&&up.device_id=qpd.device_id&&qpd.question_id=qd.question_id
where up.university='山东大学'&&up.device_id=qpd.device_id&&qpd.question_id=qd.question_id
group by qd.difficult_level;
//还是和之前求平均数一样要注意分母的去重