When a query groups rows, or uses a column function such as SUM or COUNT, each item in the select list must produce one value per group. A plain column that is neither in GROUP BY nor inside a column function does not, so Db2 stops the statement before running it.
Typical causes
A column selected next to SUM, COUNT, MAX or similar with no GROUP BY at all.
A selected column missing from the GROUP BY list.
An expression in the select list that does not exactly match a grouping expression.
A HAVING clause with no GROUP BY, which counts as grouping with no columns, so no plain column may be selected.
An ORDER BY sort key that mixes grouped and non-grouped data in a grouped result.
How to fix it
Add every plain selected column or expression to GROUP BY, written the same way as in the select list.
Or remove the column from the select list if you do not need it per group.
Or wrap the column in a column function if one value per group is what you want.
Rerun the statement.
Example
Illustrative only; names and values are invented.
SQLCODE = -122, SQLSTATE 42803
-- SELECT DEPT, COUNT(*) FROM EMP (DEPT is not grouped)