AVG function [Aggregate]

Function

Computes the average of a numeric expression for a set of rows, or computes the average of a set of unique values.

Syntax

AVG ( numeric-expression   |  DISTINCT column-name  )

Parameters

numeric-expression The value whose average is calculated over a set of rows.

DISTINCT column-name Computes the average of the unique values in column-name. This is of limited usefulness, but is included for completeness.

Example

The following statement returns the value 49988.6.

SELECT AVG ( salary ) FROM employee

Usage

This average does not include rows where numeric -expression is the NULL value. Returns the NULL value for a group containing no rows.

Standards and compatibility

See also

“SUM function [Aggregate]”

“COUNT function [Aggregate]”