sql 'Invalid use of group function
时间: 2023-10-19 12:01:39 浏览: 163
在Oracle中执行双层SUM函数不会报错,但在MySQL中执行相同的SQL会报错"Invalid use of group function"。这个错误是因为在MySQL中,当使用GROUP BY子句进行分组操作时,不能在WHERE子句中使用聚合函数,如SUM、COUNT等。WHERE子句的作用是在分组之前过滤数据,而聚合函数是在分组之后才能计算的。因此,需要将聚合函数放在HAVING子句中来进行条件筛选。这样,在MySQL中执行相同的SQL时,需要将WHERE子句中的聚合函数移至HAVING子句中,以避免"Invalid use of group function"错误的发生。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mysql :error 1111. Invalid use of group function](https://blog.csdn.net/kang1011/article/details/106463122)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [SQL初学时最常出现的错误(一)Invalid use of group function](https://blog.csdn.net/msqynl311833/article/details/98963040)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文