← All errors

SQLCODE -122

SQL0122 Column not grouped in SELECT

IBM message text
Column &1 or expression in SELECT list not valid.
SQLCODE
-122
SQLSTATE
42803

Most common cause

The SELECT has a column that is not in GROUP BY and not inside an aggregate function.

Other causes

  • An aggregate function and a column in SELECT, with no GROUP BY.
  • A different expression in SELECT and GROUP BY (for example a SUBSTR with different arguments).
  • An ORDER BY column that breaks the grouping.

How to fix it

Add the column to GROUP BY, or aggregate it (MAX, MIN, SUM).

Related errors

Text and codes from IBM documentation for 7.6. Checked on .