mysql group by max
时间: 2023-08-25 09:05:24 浏览: 103
在MySQL中,使用GROUP BY和MAX函数可以实现按最大值分组。通过将字段作为GROUP BY的参数,将结果按照该字段进行分组。然后使用MAX函数获取每个分组中的最大值。例如,可以使用以下查询来实现按最大值分组的功能: SELECT name, MAX(score) FROM sc GROUP BY name; 这将返回按照name字段分组,并在每个分组中选择最大的score值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [MySQL之group by与max()一起使用的坑](https://blog.csdn.net/qq_44690947/article/details/109133592)[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^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [MySQL GROUP BY用法](https://blog.csdn.net/weixin_30323631/article/details/98662908)[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^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文