1.首先用到的是 avg()求平均值
2.起一个别名
3.做判断
3.1用having 比较
3.2用子查询在用where
推荐使用2方式答题
答题方式1
select sp.university ,sp.avg_question,sp.avg_answer_cont
from
(select university,avg(question_cnt) as avg_question,
avg(answer_cnt) as avg_answer_cont
from user_profile
group by university ) sp
where sp.avg_question<5
or sp.avg_answer_cont<20
答题方式2
select university,avg(question_cnt) as avg_question,
avg(answer_cnt) as avg_answer_cont
from user_profile
group by university
having
avg_question<5
or
avg_answer_cont<20