U118: Column must appear in the GROUP BY clause
SQLSTATE: 42803 (Class 42 — Syntax Error or Access Rule Violation: grouping_error)
Example Postgres Log Output:
ERROR: column "identifier_column.value_column" must appear in the GROUP BY clause or be used in an aggregate function at character 8 STATEMENT: SELECT identifier_column, MAX(value_column) FROM my_table
This error occurs since you've specified an aggregate function (e.g.
alongside a regular column in the query's target list, but you didn't specify
the regular column as one of the columns to be grouped by.
Usually you would encounter this whilst testing on a development/staging system, or when mistyping a one-off query on a production system.
Be aware of GROUP BY and aggregation logic in PostgreSQL and be sure to specify the correct columns to aggregate by.
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →