Outdated Version
You are viewing an older version of this section. View current production version.
AVG
Aggregate function. Calculate the average value from a set of numbers. NULL values are ignored. If no values can be averaged, this function returns NULL.
Syntax
AVG ( [DISTINCT] expression )
Arguments
- DISTINCT: optional keyword. If present, will average the unique values.
- expression: any numerical expression. This may be a column name, the result of another function, or a math operation
Return Type
A double if the input type is double, otherwise decimal.
Examples
select avg(table_rows) from information_schema.tables;
+-----------------+
| avg(table_rows) |
+-----------------+
| 1540.0000 |
+-----------------+
1 row in set (2.87 sec)
select avg(list_price * discount) from items;
select avg(age) from employees group by job_title;