hive having
时间: 2023-08-28 21:22:45 浏览: 114
HAVING语句是在GROUP BY之后使用的,它用于对查询结果进行筛选,只返回满足条件的组。与WHERE语句不同,WHERE针对表中的列发挥作用,而HAVING针对查询结果中的列发挥作用。此外,WHERE后面不能写分组函数,而HAVING后面可以使用分组函数。在Hive中使用HAVING语句时,可以结合GROUP BY来进行分组统计操作。例如,可以使用HAVING语句找出每个部门的平均薪水大于2000的部门,通过以下语句实现:SELECT epname, avg(sal) AS avg_sal FROM emp GROUP BY epname HAVING avg_sal > 2000。这样可以得到满足条件的部门和对应的平均薪水。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Hive基本查询操作](https://blog.csdn.net/weixin_45618366/article/details/106475693)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Hive(四):where和having](https://blog.csdn.net/chandelierds/article/details/107932046)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文