Bug #62053 | columns in SELECT clause not affected by group fn must be declared in GROUP BY | ||
---|---|---|---|
Submitted: | 2 Aug 2011 4:14 | Modified: | 2 Aug 2011 4:22 |
Reporter: | LUIS ANTONIO GAMA MORENO | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S1 (Critical) |
Version: | 5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | GROUP BY, group functions |
[2 Aug 2011 4:14]
LUIS ANTONIO GAMA MORENO
[2 Aug 2011 4:22]
Valeriy Kravchuk
Please, read the manual, http://dev.mysql.com/doc/refman/5.5/en/group-by-hidden-columns.html, where this situation is explained in details. Set ONLY_FULL_GROUP_BY SQL mode if you need standard behavior: ... mysql> SELECT deptno, SUM(sal) -> FROM emp; +--------+----------+ | deptno | SUM(sal) | +--------+----------+ | 10 | 21500.00 | +--------+----------+ 1 row in set (0.04 sec) mysql> set sql_mode='ONLY_FULL_GROUP_BY'; Query OK, 0 rows affected (0.02 sec) mysql> SELECT deptno, SUM(sal) FROM emp; ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause mysql>