A group is a set of rows having the same value on specific columns. In Chapter 3, “Query Output” you learned how to apply aggregate functions on all output rows. In this chapter you learn how to create groups and apply aggregate functions on those groups.
In a query the GROUP BY clause appears after the WHERE clause and before the ORDER clause, if any. Here is the syntax for a SELECT statement with the WHERE, GROUP BY, and ORDER BY clauses.
GROUP BY group_columns
ORDER BY column(s);
As an example, the query in Listing 4.1 groups the output from the product table by their launch date.
Listing 4.1: Grouping on one column