Chapter 6. Summarizing and Grouping Data
The preceding chapter described scalar functions, which operate on individual row values. This chapter introduces SQL’s aggregate functions, or set functions, which operate on a group of values to produce a single, summarizing value. You apply an aggregate to a set of rows, which may be:
All the rows in a table
Only those rows specified by a WHERE clause
Those rows created by a GROUP BY clause
No matter how many rows the set contains, an aggregate function returns a single statistic: a sum, minimum, or average, for example.
In this chapter, I’ll also cover the SELECT statement’s GROUP BY clause, which groups rows, and HAVING clause, which filters groups.
Get SQL: Visual QuickStart Guide 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.