|expression1, expression2, ... expression_n||The expressions that are not encapsulated within an aggregate function and must be included in the GROUP BY clause.|
|aggregate_function||A function such as SUM, COUNT, MIN, MAX, or AVG functions.|
|tables||he tables that you wish to retrieve records from. There must be at least one table listed in the FROM clause.|
|WHERE conditions||Optional. The conditions that must be met for the records to be selected.|
The MySQL GROUP BY clause is used in a SELECT statement to collect data across multiple records and group the results by one or more columns.
Its behavior is governed in part by the value of the
ONLY_FULL_GROUP_BY variable. When this is enabled,
SELECT statements that group by any column not in the output return an error. (This is the default as of 5.7.5.) Both setting and not setting this variable can cause problems for naive users or users accustomed to other DBMSs.