题解 | 分组过滤练习题
分组过滤练习题
https://www.nowcoder.com/practice/ddbcedcd9600403296038ee44a172f2d
select university, avg(question_cnt) as avg_question_cnt, avg(answer_cnt) as avg_answer_cnt from user_profile group by university having avg_question_cnt<5 or avg_answer_cnt<20
根据题意:取出平均发贴数低于5的学校或平均回帖数小于20的学校。
题目分析:根据返回示例表头改名 ,用as;
平均数,用AVG函数;avg( *)
要统计每个学校的平均发贴数和平均回帖数用 group by university
最后,聚合函数结果作为筛选条件时,不能用where,而是用having语法,这是细节。
#分组过滤器#