Versions available for this page: CUBRID 8.2.1 | CUBRID 8.3.0 | CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 | CUBRID 8.4.3 | CUBRID 9.0.0 |
The AVG function calculates the arithmetic average of an expression with a single value. You can use any data type that can be added or divided by a number. The data type of the attribute to be averaged is maintained. For example, if the attribute is a floating point value, the AVG function also returns a FLOAT. You cannot get the average of a collection.
AVG ( [ DISTINCT | UNIQUE | ALL ] expression )
When calculating the average of a value specified in an expression, you can determine whether to include all instances or only unique values.
The following is an example that returns the average number of gold medals that Korea won in the Olympic Games from 1988 to 2004.
SELECT AVG(gold)
FROM participant
WHERE nation_code = 'KOR';
Result : 9