题解 | 分组过滤练习题

分组过滤练习题

https://www.nowcoder.com/practice/ddbcedcd9600403296038ee44a172f2d

#思路: 先将表中数据按照大学名字进行分组并计算每组的聚合函数,然后对group by分组后的结果用having进行过滤约束
#注意: group by的结果用having,而不是where
select 
    university,
    ROUND(AVG(question_cnt),3) avg_question_cnt,
    ROUND(AVG(answer_cnt),3) avg_answer_cnt 
from user_profile 
GROUP BY university 
having avg_question_cnt < 5.000 or avg_answer_cnt < 20.000; 

全部评论

相关推荐

不知道怎么取名字_:玩游戏都写到简历上了啊
投递BOSS直聘等公司6个岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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