bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL Tutorial
SQL•SQL Tutorial

SQL AVG() Function

The SQL AVG() Function

The AVG() function returns the average value of a numeric column. The AVG() function ignores NULL values in the column.

Example

Find the average price of all products:

SELECT AVG(Price)

FROM Products;

Note:

NULL values are ignored.

AVG() Syntax

Select Avg(

column_name )

From

table_name

Where

condition

;

Demo Database

Below is a selection from the

Products table used in the examples:

ProductID

ProductName

SupplierID

CategoryID

Unit

Price

Chais

10 boxes x 20 bags 18.00

Chang

Formula

24 - 12 oz bottles

19.00

Aniseed Syrup

Formula

12 - 550 ml bottles

10.00

Chef Anton's Cajun Seasoning

Formula

48 - 6 oz jars

22.00

Chef Anton's Gumbo Mix

36 boxes 21.35

Add a WHERE Clause

You can add a WHERE

clause to specify conditions:

Example

Return the average price of products in category 1:

Previous

SQL SUM() Function

Next

SQL LIKE Operator