The GROUP BY clause allows you to group rows that have the same values into summary rows. This clause is often used with aggregate functions, which were covered in the previous section of this chapter. It's an optional clause that can be used on a SELECT statement.
The following code shows the GROUP BY syntax, where the WHERE and ORDER BY clauses are optional:
SELECT column(s)
FROM table
WHERE condition(s)
GROUP BY columns(s)
ORDER BY column(s);