AVG()

AVG() is an aggregate function that returns the average (mean) of the values in a numeric column. Like other aggregates, it skips NULL values.

SQL

It is the quick way to find a typical value, such as the average order amount or the average age of your users.

Because AVG ignores NULLs, the average is taken over only the rows that actually have a value, not the full row count.

Syntax

SELECT AVG(column) FROM table_name;

Examples

SQL

SELECT AVG(age) AS avg_age
FROM users;

Output:

avg_age
-------
29.5

Learn it in a lesson

See also

Back to the Dictionary