The
SUM Function is used to get the sum of a specified field from a given set of records.
SQL SUM() SYNTAX
Select SUM(column_name) from tablename;
The SUM Function Example
The
Products table has the following records:
Prd001 |
Pen |
40.25 |
Prd002 |
Pen |
100.75 |
Prd003 |
Eraser |
10.35 |
Prd004 |
Pencil |
20.45 |
Prd005 |
Book |
50.65 |
Prd006 |
Gum |
25.22 |
To obtain the
sum of the prices of the products, use the 'sum' function on the ProductPrice column as shown below.
Select SUM(ProductPrice) as
ProductTotal From Products;