SQL SERVER

SQL Server ROLLUP

SQL Server ROLLUP
Written by shohal

SQL Server ROLLUP

The SQL Server ROLLUP is a subclause of the GROUP BY clause which provides a shorthand for defining multiple grouping sets.

ROLLUP(d1,d2,d3) creates only four grouping sets, assuming the hierarchy d1 > d2 > d3, as follows:

Union All

Union All

Using UNION ALL with GROUP BY

Using ROLLUP with GROUP BY

About the author

shohal

Leave a Comment