SQL Dialects Reference/Functions and expressions/Math functions/Aggregate functions

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

[edit] Aggregate functions

This page includes comparison tables which can be big and complex.

While it's perfectly all right to view them in their complete state, it is recommended to install a comparison tables extension that would allow to select particular columns of interest for comparison.

ANSI/ISO SQL Level Feature-ID Function DB2 SQLite MySQL PostgreSQL Firebird Virtuoso Oracle MSSQL Linter
SQL:2003/200n (core) E091-02 Count non-NULL values in x COUNT([DISTINCT] x)  ? COUNT([DISTINCT] x) COUNT([DISTINCT] x) COUNT([DISTINCT] x)  ? COUNT(x) COUNT([DISTINCT] x) COUNT([DISTINCT] x)
SQL:2003/200n (core) E091-05 Sum of x SUM([DISTINCT] x)  ? SUM(x) SUM([DISTINCT] x) SUM(x)  ? SUM(x) SUM([DISTINCT] x) SUM([DISTINCT] x)
SQL:2003/200n (core) E091-01 Average of x AVG([DISTINCT] x) AVG(x) AVG([DISTINCT] x) AVG([DISTINCT] x) AVG(x)  ? AVG(x) AVG([DISTINCT] x) AVG([DISTINCT] x)
SQL:2003/200n Minimum value in x MIN(x) MIN(x) MIN(x) MIN(x) MIN(x)  ? MIN(x) MIN(x) MIN(x)
SQL:2003/200n Maximum value in x MAX(x) MAX(x) MAX(x) MAX(x) MAX(x)  ? MAX(x) MAX(x) MAX(x)
SQL:2003/200n Range (max - min) of x  ?  ?  ?  ?  ?  ?  ?  ?  ?
SQL:2003/200n Standard deviation STDDEV([DISTINCT] x) N/A STD(x)
STDDEV(x)
STDDEV_POP(x)
STDDEV(x)
STDDEV_POP(x)
STDDEV_SAMP(x)
N/A STDDEV(x, y) STDDEV([DISTINCT|ALL] x) STDEV(x)
STDEVP(x)
STDDEV([DISTINCT] x)
SQL:2003/200n Variance VARIANCE([DISTINCT] x) N/A VARIANCE(x)
VAR_POP(x)
VARIANCE(x)
VAR_POP(x)
VAR_SAMP(x)
N/A VAR(x) VARIANCE(x) VAR(x)
VARP(x)
VARIANCE([DISTINCT] x)