avg

Calculates the numeric average of all (distinct) values.

Syntax

avg([all | distinct] expression)

Parameters

Examples

Usage

  • avg, an aggregate function, finds the average of the values in a column. avg can only be used on numeric (integer, floating point, or money) datatypes. Null values are ignored in calculating averages.

  • When you average (signed or unsigned) int, smallint, tinyint data, the SAP ASE server returns the result as an int value. When you average (signed or unsigned) bigint data, the SAP ASE server returns the result as a bigint value. To avoid overflow errors in DB-Library programs, declare variables used for resultrs appropriately.

  • You cannot use avg with the binary datatypes.

  • Since the average value is only defined on numeric datatypes, using avg Unicode expressions generates an error.

See also Transact-SQL Users Guide.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute avg.

Related concepts
Expressions
Related reference
max
min