题解 | #分组计算练习题#

分组计算练习题

http://www.nowcoder.com/practice/009d8067d2df47fea429afe2e7b9de45

关于分组的题本人做的不是特别的好,一旦条件复杂了我就无从下手,但是想起来老师说的一句话,程序是一遍一遍打磨,一次一次磨练出来的,从不完美到完美,为此我根据题意一句一句进行拆解: #30天内平均活跃天数和平均发帖数量

select avg(active_days_within_30),avg(question_cnt) from user_profile

#按照学校进行分组的各个学校的用户数

select count(id) from user_profile group by university

#每个学校每种性别的用户数

select count(id) from user_profile group by university,gender

得出最终结果: select gender,university,count(id), avg(active_days_within_30),avg(question_cnt) from user_profile group by university,gender

全部评论

相关推荐

下个早班:秒挂就是不缺人
点赞 评论 收藏
分享
07-01 13:37
门头沟学院 Java
steelhead:不是你的问题,这是社会的问题。
点赞 评论 收藏
分享
评论
33
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务