SQL Flow Field Guide

GROUP BY () (grand total)

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

empty grouping set: aggregates over all rows

What changes

Input
rows after WHERE
Output or change
single grand-total row

Syntax at a glance

GROUP BY ( )

Work example

A report needs one grand total across all qualifying rows.

Compare the empty grouping set with a grouped result. Check how an empty input is represented.

Check your work GROUP BY () (grand total). The empty grouping set returns one aggregate row and does not split by a key.

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