Using Aggregate Functions
Table 6.1 lists SQL’s standard aggregate functions. The important characteristics of the aggregate functions are:
In Table 6.1, expr often is a column name, but it also can be a literal, function, or any combination of column names, literals, and functions coupled by operators.
SUM() and AVG() work with only numeric data types. MIN() and MAX() work with characters, numeric, and datetime data types. COUNT(expr) and COUNT(*) work with all data types.
All aggregate functions except COUNT(*) ignore nulls. (You can use COALESCE() in an aggregate function argument to substitute a value for a null; see “Checking for Nulls with COALESCE()” in Chapter 5.)
COUNT(expr) and COUNT(*) never return null but return either a positive integer ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access