When using the GROUP BY
clause in SQL Server, we can use the ROLLUP
modifier to create subtotals and grand totals, etc.
You may have seen two variations of this. One as GROUP BY ROLLUP ()
and the other as GROUP BY ... WITH ROLLUP
.
You may be wondering which one you should use?
As it turns out, Microsoft recommends that we use the first syntax; GROUP BY ROLLUP ()
. The other syntax is provided for backward compatibility only.