Home » Tutorials » SQL » SQL AVG FUNCTION

SQL AVG FUNCTION

The AVG() function returns the average value of a numeric column.

SQL AVG() Syntax:

SELECT AVG (Column) FROM Table

Example

We have the following “Orders” table:

OrderIDCustomerDateOrderPrice
1Jones2012/01/011000
2Smith2012/01/021600
3Watson2012/01/02700
4Jones2012/01/03300
5Brown2012/01/032000
6Smith2012/01/04100

Now we want to find the average value of the “OrderPrice” fields.

We use the following SQL statement:

SELECT AVG (OrderPrice) AS (OrderAverage) From Orders

The result-set will look like this:

OrderAverage: 950



Link/cite this page

If you use any of the content on this page in your own work, please use the code below to cite this page as the source of the content.

  • Stewart, Suzy. "SQL AVG FUNCTION". After Hours Programming. Accessed on March 19, 2024. https://www.afterhoursprogramming.com/tutorial/sql/sql-avg-function/.

  • Stewart, Suzy. "SQL AVG FUNCTION". After Hours Programming, https://www.afterhoursprogramming.com/tutorial/sql/sql-avg-function/. Accessed 19 March, 2024.

  • Stewart, Suzy. SQL AVG FUNCTION. After Hours Programming. Retrieved from https://www.afterhoursprogramming.com/tutorial/sql/sql-avg-function/.



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.