我正在测试并试图理解和调整其他人编写的大型查询,希望获得有关 GROUP BY 部分中整数含义的帮助。它具有以下结构:
SELECT
column1,
column2,
SUM(column3),
SUM(column4),
FROM
table1 AS a
WHERE
column5 <> 3
GROUP BY
column1,
7,
column2;
那 7 有什么作用?我真的无法在输出的任何地方找到它,也看不到它产生了什么影响。
最佳答案
documentation of the SELECT
statement解释:
查询中的Columns selected for output can be referred to in
ORDER BY
andGROUP BY
clauses using column names, column aliases, or column positions.
Column positions are integers and begin with 1.
GROUP BY 7
不是有效的列位置,因为 SELECT
子句仅包含 4
表达式。
关于mysql - GROUP BY 子句中整数的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48944554/