AVG Function [Aggregate]

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

Syntax

AVGnumeric-expression  | DISTINCT column-name )

Parameters

Parameter

Description

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

Returns

Returns the NULL value for a group containing no rows.

Returns DOUBLE if the argument is DOUBLE, otherwise NUMERIC.

Example

The following statement returns the value 49988.6:

SELECT AVG ( salary ) FROM Employees

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

  • SQL—ISO/ANSI SQL compliant.

  • Sybase—Compatible with Adaptive Server Enterprise.

Related reference
COUNT Function [Aggregate]
SUM Function [Aggregate]