O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required