题解 | #分组过滤练习题#
分组过滤练习题
https://www.nowcoder.com/practice/ddbcedcd9600403296038ee44a172f2d
SELECT university, ROUND(AVG(question_cnt),3) AS avg_question_cnt, ROUND(AVG(answer_cnt),3) AS avg_answer_cnt FROM user_profile GROUP BY university HAVING (avg_question_cnt < 5 OR avg_answer_cnt < 20)
HAVING 子句
在 SQL 中增加 HAVING 子句原因是,WHERE 关键字无法与聚合函数一起使用。
HAVING 子句可以让我们筛选分组后的各组数据。