Geek University

SQL AVG() Function

The AVG() function is used to return the average value of a specific numeric column in the table. The syntax:

SELECT AVG(column1) FROM table1;

Here is how we can calculate the average product price from the Products table using the AVG() function:

SELECT AVG(buyPrice) AS avgPrice FROM products;

This would produce the following result:

+--------------------+
| avgPrice           |
+--------------------+
| 54.395181818181825 |
+--------------------+

Subscribe to our Newsletter

Like us on Facebook

Share on Twitter

top
Developed by Signum Soft