AVG returns the aggregate average of values.


AVG( [ DISTINCT | ALL ] expression )


  • DISTINCT | ALL: Specifying the DISTINCT keyword excludes duplicate values from the calculation.

    • Specifying ALL explicitly includes all values, including duplicates.

    • ALL is the default behavior and is not required.

  • expression: The name of an expression on which to average values. expression must resolve to a value that can be averaged.


The average of the values.

Additional Information

  • Multiple aggregate functions can be combined in the same query, so long as they comply with the following:

  • Only one DISTINCT keyword can be used per query. This means that if you are submitting both an AVG function and SUM function in the same query, only one can include the DISTINCT function, even though DISTINCT is supported with each function if submitted individually.


SELECT AVG(salesTotal) FROM MYSQL.inventory.cust;

SELECT AVG(avgColumn) FROM (VALUES (1), (2), (3)) AS myTable (avgColumn);
-- Returns 2

SELECT AVG(DISTINCT avgColumn) FROM (VALUES (2), (2), (4)) AS myTable (avgColumn);
-- Returns 3