AVG(expression)

Description: Returns the average value of expression. Generally used with GROUP BY clause, but otherwise will operate on all rows returned.

Example:

SELECT city_name, AVG(temperature)
  FROM weather
  GROUP BY city_name

returns the average temperature recorded for each city in the weather table.

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.