The GROUP BY Clause
The GROUP BY statement is often used with aggregate functions (such as COUNT, MAX, and SUM) so that you can group a set of rows by one or more columns. Here’s a high-level overview of how you can use it, as well as information on how it works and some tips to keep in mind.
As an example, here’s a table with some pets data.
We can count the number of each species present in our table using the GROUP BY clause.
How the GROUP BY Clause Works