MySQL 5:这与我的GROUP BY字段的顺序有关系吗? [英] MySQL 5: Does it matter what order my GROUP BY fields are in?

查看:426
本文介绍了MySQL 5:这与我的GROUP BY字段的顺序有关系吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Peeps,

我的MySQL查询中有几个聚合/计算字段。我的GROUP BY子句是动态生成的,具体取决于用户在Web表单中选择的选项。好奇的是,如果GROUP BY子句中列出的字段顺序可能会对计算产生任何影响(比如SUM,AVERAGE等)

谢谢!

解决方案

如果您使用的是 WITH ROLLUP ,将会很重要,否则不应该。 / p>

Peeps,

I have a few aggregate/calculated fields in my MySQL query. My GROUP BY clause is dynamically generated, depending on what options a user selects in a web form. Curious if the order of fields listed in the GROUP BY clause can have any impact on the calculations (things like SUMs, AVERAGEs, etc)

Thanks!

解决方案

It WILL matter if you are using WITH ROLLUP, otherwise, it should not.

这篇关于MySQL 5:这与我的GROUP BY字段的顺序有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆