ANSI SQL Aggregate Functions
Aggregate functions return a single value based upon a set of other values. If used among other expressions in the item list of a SELECT statement, the SELECT must have a GROUP BY or HAVING clause. No GROUP BY or HAVING clause is required if the aggregate function is the only value retrieved by the SELECT statement. The supported aggregate functions and their syntax are listed in Table 4-1.
|
Function |
Usage |
AVG(
|
Computes the average value of a column given by
|
CORR( |
Computes a correlation coefficient. |
COUNT(
|
Counts the rows defined by the |
COUNT(*) |
Counts all rows in the specified table or view. |
COVAR_POP ( |
Computes population covariance. |
COVAR_SAMP( |
Computes sample covariance. |
CUME_DIST( |
Computes the relative rank of a hypothetical row within a group of rows, where the rank is equal to the number of rows less than or equal to the hypothetical row divided by the number of rows in the group. |
DENSE_RANK( |
Generates a dense rank (no ranks are skipped) for a hypothetical row
( |
MIN(
|
Finds the minimum value in a column given by
|
MAX(
|
Finds the maximum value in a column given by
|
PERCENT_RANK(
|
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