题解 | #统计每个学校各难度的用户平均刷题数#
统计每个学校各难度的用户平均刷题数
https://www.nowcoder.com/practice/5400df085a034f88b2e17941ab338ee8
select
a.university,
c.difficult_level,
round(
(count(b.question_id)) / (count(distinct b.device_id)),4) as avg_answer_cnt
from
user_profile as a,
question_practice_detail as b,
question_detail as c
where
a.device_id = b.device_id
and b.question_id = c.question_id
group by
a.university,
c.difficult_level
having用于对分组的条件筛选
where用于对列的条件筛选
group by 放在where 之后,放在having之前
计算平均每个学校各难度的用户平均刷题数 公式要注意
