SQL Flow Field Guide

SUM

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

aggregation

What changes

Input
the argument expression over each group's rows (COUNT(*) reads no column)
Output or change
one value per group (or one for the whole input when there is no GROUP BY)
Return type
Returns the summation of all expression values in the most precise expression data type. Expression result Return type tinyint int smallint int int int bigint bigint decimal category (p, s) decimal(38

Syntax at a glance

SUM ( [ ALL | DISTINCT ] expression )

Work example

Add amounts or quantities within each report group.

Group by the business key and choose a decimal input with enough precision and scale.

Check your work SUM ignores null inputs and returns null when a group has no nonnull values.

Practice SQL

Open in SQL Flow
SELECT SUM(amount) AS total FROM (VALUES (12.50), (7.25), (NULL)) AS v(amount);

Open Microsoft Learn for full syntax, permissions, and details for your version.