Column must appear in the GROUP BY clause / isn't in GROUP BY (MySQL 1055 only_full_group_by)
You selected a column that is neither grouped nor aggregated, so the result would be ambiguous.
Meaning
Each output row of a GROUP BY represents many input rows. Non-aggregated columns must be in the GROUP BY (or functionally dependent on it). MySQL 5.7+ enforces this with ONLY_FULL_GROUP_BY (error 1055); PostgreSQL always has.
Common causes
- SELECT includes a column not in GROUP BY and not aggregated
- Code written for old MySQL defaults that silently picked a random row
- ORDER BY a non-grouped column
⚡ Quick fix
- Add the column to GROUP BY, or wrap it in an aggregate (MAX, MIN, ANY_VALUE)
- Group by the primary key when selecting many columns from that table
- Avoid disabling ONLY_FULL_GROUP_BY — it hides real bugs
Detailed fix by platform
SQL
- Aggregate or group explicitly:sql
-- ❌ which order's created_at should be shown per customer? SELECT customer_id, created_at, COUNT(*) FROM orders GROUP BY customer_id; -- ✅ SELECT customer_id, MAX(created_at) AS last_order, COUNT(*) AS orders FROM orders GROUP BY customer_id;
How to diagnose
- Column — Which column is named?
- Intent — Which value do you actually want per group?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026