O'Reilly logo

Practical SQL Handbook, The: Using SQL Variants, Fourth Edition by Sandra L. Emerson, Marcy Darnovsky, Judith S. Bowman

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

Aggregate Syntax

The general syntax of the aggregate functions is this:

aggregate_function([DISTINCT] expression)

Since aggregates are functions, they always take an argument. The argument is an expression, and it is enclosed in parentheses. The expression is often a column name, but it can also be a constant, a function, or any combination of column names, constants, and functions connected by arithmetic operators. Figure 5.1 lists the aggregate functions.

Figure 5.1. Aggregate Functions

You can use DISTINCT with any aggregate except COUNT(*). However, note that DISTINCT gives you no advantage with MIN and MAX because the minimum distinct price ...

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