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.
must appear in the GROUP BY clauseisn't in GROUP BYnot functionally dependentnonaggregated column 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in SQL
- readonly database sqlite3.OperationalError: attempt to write a readonly database
- unable to open database sqlite3.OperationalError: unable to open database file
- Network-related error SQL Server: A network-related or instance-specific error occurred while establishing a connection to SQL Server. (provider: Named Pipes Provider, error: 40 / TCP Provider, error: 26)
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026