# Postgres error 42803: column "x" must appear in the GROUP BY clause or be used in an aggregate function

> A grouped query selects a column that is neither grouped nor aggregated.

Source: https://scribase.com/postgres-errors/42803

SQLSTATE class: Syntax Error or Access Rule Violation. Over PostgREST/supabase-js this maps to HTTP 400.

## Causes

- Selecting extra columns next to count(*) or sum().

## Fixes

- Add the column to GROUP BY, wrap it in an aggregate (max, array_agg), or group by the primary key (Postgres then allows the other columns of that table).