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

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.