GROUP BY and HAVING
In this chapter we will discuss how to use aggregation, grouping, and the HAVING clause in a SELECT. By using these added features, we can group data of a particular type, filter the output with HAVING, and do combinations of aggregate calculations (such as sums, averages, and counts). We will also take another look at nulls.
As we discussed in Chapter 4, an aggregate (or group) function is one that extracts information — such as a COUNT of rows in a table. We can also find an average, minimum, or maximum for some column by operating on multiple rows. Some examples are:
We can now proceed ...