13
Grouping Data
In this chapter, you’ll learn how to group data so you can summarize subsets of table contents. Grouping data involves two SELECT
statement clauses that you haven’t learned about yet: the GROUP BY
clause and the HAVING
clause.
Understanding Data Grouping
In the previous chapter, you learned that the SQL aggregate functions can be used to summarize data. By using those functions, you can count rows, calculate sums and averages, and obtain high and low values without having to retrieve all the data.
All the calculations thus far have been performed on all the data in a table or on data that matched a specific WHERE
clause. As a reminder, the following example returns the number of products offered by vendor 1003:
Input
SELECT ...
Get MySQL Crash Course, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.