No Group By Function
schema:gisq
ORA-00937: not a single-group group function
Error 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
ORA-00937: not a single-group group function
Error 7 ERROR: Attribute xxx.xxx must be GROUPed or used in an aggregate function
ORA-00937: not a single-group group function
ORA-00937: not a single-group group function
Problem
Usually we must have a GROUP BY clause if in aggregate function (such as SUM or COUNT) is used.
The exception is when only aggregate functions are used on the SELECT clause. If we mix aggregate and non-aggregate values then there must be a GROUP BY clause.
Solutions
- Remove the offending field from the SELECT line
- Add the field to the GROUP BY clause
- Aggregate the offending field
SELECT name, MAX(population)
FROM bbc