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筛选,having常用于对分组结果进行筛选。
这里不能使用where的原因是 where的执行顺序早于groupby,所以where 也不可以使用 列的别名。而having可以。