AVG Function

Description

The AVG function calculates the arithmetic average of the value of an expression representing all rows. Only one expression is specified as a parameter. You can get the average without duplicates by using the DISTINCT or UNIQUE keyword in front of the expression or the average of all values by omitting the keyword or by using ALL.

Syntax

AVG ( [ { DISTINCT | DISTINCTROW } | UNIQUE | ALL ] expression )

Example

The following example shows how to retrieve the average number of gold medals that Korea won in Olympics (demodb).

SELECT AVG(gold)

FROM participant

WHERE nation_code = 'KOR';

Result value : 9