The AVG() function returns the average value of a numeric column.
The SUM() function returns the total sum of a numeric column.
Below is a selection from the "Products" table in the Northwind sample database:
The following SQL statement finds the number of products:
Note: NULL values are not counted.
The following SQL statement finds the average price of all products:
Note: NULL values are ignored.
Below is a selection from the "OrderDetails" table in the Northwind sample database:
The following SQL statement finds the sum of the "Quantity" fields in the "OrderDetails" table:
Note: NULL values are ignored.