SQL COUNT(), AVG() and SUM() Functions
The SQL COUNT(), AVG() and SUM() Functions
The COUNT() function returns the number of rows that matches a specified criteria.
The AVG() function returns the average value of a numeric column.
The SUM() function returns the total sum of a numeric column.
COUNT() Syntax
AVG() Syntax
SUM() Syntax
Demo Database
Below is a selection from the "Products" table in the Northwind sample database
SUM()
The following SQL statement finds the sum of the "Quantity" fields in the "OrderDetails" table:
Last updated