MS Access Sum() Function

The Sum() function in MS Access calculates the sum (total) of a set of numeric values. It's a fundamental aggregate function—it works across multiple rows to give a single result.



Sum(): Definition and Usage

Sum() is extremely useful for summarizing numerical data in your database. It adds up all the non-null numeric values in the specified column or expression. NULL values are automatically ignored in the calculation.

Syntax

Syntax

Sum(expression)
      

Parameter Values

Parameter Description
expression A numeric field (column) name or a formula that evaluates to a number. This is required.

Example

Calculating the Total Quantity

This example calculates the total of the 'Quantity' column in the 'OrderDetails' table. (This assumes that a 'OrderDetails' table exists with a 'Quantity' column containing numeric data.)

Syntax

SELECT Sum(Quantity) AS TotalItemsOrdered FROM OrderDetails;
      
Output

TotalItemsOrdered
-----------------
(The sum of all non-null Quantity values in the OrderDetails table)
      

**Note:** The example output will show the sum of all non-null values in the `Quantity` column of your `OrderDetails` table. If the table is empty or contains only null values in the `Quantity` column, the output will be 0.