No Group By Function

Revision as of 13:20, 9 August 2012 by Andr3w (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


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.


  • 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