-
having用于聚合函数的筛选, where中不能使用聚合函数
where子句在聚合前先筛选记录,也就是说作用在group by 子句和having子句前,而 having子句在聚合后对组记录进行筛选
select university,avg(question_cnt) as ave_question_cnt,avg(answer_cnt) as avg_answer_cnt
from user_profile
group by university
having ave_question_cnt <5 or avg_answer_cnt<20