Chapter 8

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.

Aggregates/Column Functions

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:

image

We can now proceed ...

Get Practical Guide to using SQL in Oracle now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.