Tag Archives: SELECT list is not in GROUP BY clause and contains nonaggregated column

[MySQL] The principle of group by aggregation function and the reason for aggregation limitation SELECT list is not in GROUP BY clause and contains nonaggregated column

The principle of group by is 

First divide the data into groups according to the grouping field,

Then perform specific aggregation operations in each group

 

The limitations of ONLY_FULL_GROUP_BY mode are:

SELECT list is not in GROUP BY clause and contains nonaggregated column

In the columns of the select query, there are fields that are not in the group by clause, and there are fields that are not aggregate functions

 

The reason is that:

After group by, all fields and attributes are the attributes of this group

Among the attributes of a group, only if the maximum/minimum/average/total is known, this aggregated attribute is meaningful

The attributes of each individual group member are meaningless 

That’s why this restriction appears