题解 | #统计每个用户的平均刷题数#
统计每个用户的平均刷题数
http://www.nowcoder.com/practice/f4714f7529404679b7f8909c96299ac4
select university, qd.difficult_level,
# 设备id是用户数,注意去重
count(answer_cnt)/count(distinct up.device_id) avg_answer_cnt
from user_profile up
join question_practice_detail qpd
on up.device_id = qpd.device_id
join question_detail qd
on qd.question_id = qpd.question_id
where up.university = '山东大学'
# //这里排序两个都要考虑
group by up.university, qd.difficult_level