AVG Function in SQL

Level 238 keystrokes

AVG function calculates the average of a numeric column.

SQL code

-- AVG returns the mean of age (sum divided by the count of non-NULL values)
-- NULL ages are ignored; AS average names the result column
1SELECT AVG(age) AS average FROM users;

Output

+---------+
| average |
+---------+
|   32.60 |
+---------+
1 row in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • ;× 1
  • (× 1
  • )× 1

More SQL examples at level 2

← SQL typing practice