题解 | #分组排序练习题#
分组排序练习题
https://www.nowcoder.com/practice/e00bbac732cb4b6bbc62a52b930cb15e
思路
- 数据源:user_profile
- 筛选条件:无
- 哪些字段
- 大学:university
- 用户平均发帖情况:avg(question_cnt) as avg_question_cnt
- 聚合字段:不同大学group by university
- 排序字段:平均发帖情况 升序order by avg_question_cnt
组合代码如下:
select university
,avg(question_cnt) avg_question_cnt
from user_profile
group by university
order by avg_question_cnt
