SQLite AVG() Function
The AVG() Function
AVG() returns the average value of a column.
This example finds the average price of all the products:
AVG With WHERE
This example finds the average price of the products in category 1:
Round the Average
An average often has many decimals. Use ROUND() to round it, here to two decimals:
Higher Than Average
This example selects the products that cost more than the average price. It uses a query inside a query, called a subquery:
AVG for Each Group
Example
Find the average price in each category:
SELECT CategoryID, AVG(Price) AS AveragePrice
FROM Products
GROUP BY CategoryID;
Try it Yourself »