Learn T-SQL With Erik: Grouping Sets vs Union All
Going Further
If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 25% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that, and need to solve database performance problems quickly. You can also get a quick, low cost health check with no phone time required.
Good thing you added that semi-colon in there. It’d be a shame if your code stopped working in versions of SQL Server after 2008, now that ending a query with no semi-colon has been deprecated!