【场景】:不同大学的用户平均发帖情况 【分类】:分组排序
分析思路
select 查询结果 [学校;avg(答题记录) as avg_question_cnt]
from 从哪张表中查询数据[user_profile]
group by 分组条件[学校]
order by 对查询结果排序[平均发帖情况升序]
求解代码
方法一:
select
university,
avg(question_cnt) as avg_question_cnt
from user_profile
group by university
order by avg_question_cnt