Common SQL Errors

MySQL Error 1055: ER_WRONG_FIELD_WITH_GROUP - Fix '%s' isn't in GROUP BY

Galaxy Team
August 5, 2025

The query selects a column that is neither aggregated nor listed in GROUP BY while ONLY_FULL_GROUP_BY is enabled.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1055 ER_WRONG_FIELD_WITH_GROUP?

MySQL Error 1055: ER_WRONG_FIELD_WITH_GROUP occurs when a SELECT list includes a column not present in GROUP BY or an aggregate function while ONLY_FULL_GROUP_BY is active. Add the column to GROUP BY or wrap it in an aggregate like MAX() to resolve the issue.

Error Highlights

Typical Error Message

%s' isn't in GROUP BY

Error Type

Syntax Error

Language

MySQL

Symbol

ER_WRONG_FIELD_WITH_GROUP

Error Code

1055

SQL State

Explanation

Table of Contents

What is MySQL error 1055 ER_WRONG_FIELD_WITH_GROUP?

Error 1055 fires when MySQL detects a non-aggregated column in the SELECT list that is absent from the GROUP BY clause while the ONLY_FULL_GROUP_BY SQL mode is enabled. The server rejects the query to enforce deterministic grouping.

The error message appears as ERROR 1055 (42000): ‘column_name’ isn’t in GROUP BY. It has existed since MySQL 5.7, when ONLY_FULL_GROUP_BY became part of the default sql_mode value.

When does the error occur?

The error occurs during query execution, not compilation.

Any SELECT that combines GROUP BY with columns that lack aggregation or group listing triggers the failure when ONLY_FULL_GROUP_BY is on.

Developers commonly meet the error after upgrading from MySQL 5.6 to 5.7 or later, because previous versions allowed non-deterministic grouping by default.

Why is it important to fix?

Leaving the error unresolved blocks query execution and downstream reports.

Ignoring it by disabling ONLY_FULL_GROUP_BY can yield non-deterministic results, leading to incorrect analytics or application bugs.

Resolving the root cause ensures deterministic aggregates, cleaner SQL, and future-proof code that works across database upgrades.

What Causes This Error?

The primary cause is selecting columns that are neither aggregated nor present in GROUP BY while ONLY_FULL_GROUP_BY is active. MySQL must know which row’s value to return for each group; without aggregation the value is ambiguous.

Another cause is implicit selection of such columns through SELECT *.

Wildcard expansion pulls in every column, some of which violate the grouping rule.

How to Fix MySQL Error 1055

Add offending columns to the GROUP BY list when they logically define the grouping key. This preserves row uniqueness and satisfies ONLY_FULL_GROUP_BY.

If the column represents a single value per group, wrap it in an aggregate such as MAX() or MIN(). Aggregating removes ambiguity while retaining the desired value.

Replace SELECT * with an explicit column list that respects GROUP BY or aggregation.

This avoids accidental inclusion of problematic fields.

Common Scenarios and Solutions

Reporting query: Selecting customer.name along with SUM(order.total) without grouping by customer.name. Solution: add customer.name to GROUP BY.

Latest record per group: Selecting non-aggregated columns while using GROUP BY id. Solution: wrap extra columns in MAX() or use window functions in MySQL 8.0.

Best Practices to Avoid This Error

Always enable ONLY_FULL_GROUP_BY in development to catch violations early.

Write explicit column lists and verify each non-aggregated column is in GROUP BY.

Use Galaxy’s SQL editor linting to highlight columns that break grouping rules before the query runs, reducing runtime surprises.

Related Errors and Solutions

MySQL Error 1140 (ER_NON_GROUPING_FIELD_USED) occurs in older versions under similar conditions. The fix is identical - aggregate or group the missing columns.

MySQL Error 1582 (ER_GRP_FUNC_IN_WHERE) appears when aggregate functions are used in WHERE instead of HAVING. Move the condition to HAVING.

.

Common Causes

Related Errors

FAQs

Why did my query start failing after upgrading to MySQL 5.7?

MySQL 5.7 enables ONLY_FULL_GROUP_BY by default. Queries that relied on non-deterministic grouping now violate the rule and raise error 1055.

Is it safe to disable ONLY_FULL_GROUP_BY?

Disabling removes the error but allows ambiguous results. It is safer to refactor queries to be deterministic.

How can Galaxy help prevent this error?

Galaxy’s editor linting flags non-aggregated columns outside GROUP BY before execution and suggests fixes with AI copilot.

Does using DISTINCT fix error 1055?

DISTINCT removes duplicates after selection and does not satisfy grouping rules. You still need GROUP BY compliance.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo