- It allows you to calculate the average value of a set of values.
AVG(DISTINCT expression)
You use the DISTINCT operator in the AVG
function to calculate the average value of the distinct values.
For example, if you have a set of values 1,1,2,3, the AVG
function with DISTINCT
operator will return 2 i.e., (1 + 2 + 3) / 3
.
Example
SELECT
AVG(buyprice) 'Average Price'
FROM
products;