The GROUP BY statement is often used with aggregate functions like COUNT, MAX, MIN, SUM, AVG to group the result-set by one or more columns.
The MYSQL GROUP BY Clause is used to collect data from multiple records and group the result by one or more column. It is generally used in a SELECT statement.
MYSQL GROUP BY Syntax
GROUP BY field_name(s)
ORDER BY field_name(s);
The following MYSQL Query lists the number of office in each city:
SELECT COUNT(office_id)as number_of_office,address FROM tbloffice GROUP BY address