Home / SQL / Reference / Aggregating

SQL AVG

Return the average (mean) of values.

Syntax

AVG(expression)

NULLs are skipped (they do not count as zero).

Example

Query (on the shop database used in the SQL course)

SELECT category, ROUND(AVG(price), 2) AS avg_price
FROM products
GROUP BY category;

Result

categoryavg_price
Books53.0
Electronics155.0
Furniture335.67
Grocery22.0
Stationery9.75

5 rows

Related

Learn it step by step in the free lesson Summarising Data, with exercises that check your queries.