gruop by 和 order by 一起用
时间: 2023-12-25 19:44:58 浏览: 71
当使用GROUP BY和ORDER BY一起时,GROUP BY子句先执行分组操作,然后ORDER BY子句对分组后的结果进行排序。然而,需要注意的是,如果在GROUP BY之后使用ORDER BY,只能实现对分组后的数据进行排序,而不会对分组内部进行排序。如果在GROUP BY之后只有一条记录,那么ORDER BY将无效。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Group By和Order By一起使用的问题](https://blog.csdn.net/tabvla/article/details/127688469)[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_2"}}] [.reference_item style="max-width: 50%"]
- *3* [MySQL聚合函数和分组时,使用Python语言和MySQL连接库示例代码.txt](https://download.csdn.net/download/weixin_44609920/88222314)[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_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文