To continue from the last video on aggregations, we saw that our aggregates in SQL didn't have any subtotals or a grand total by default. In this video, we update our GROUP BY clause to include the subtotals and grand totals in our output!
Note that if you're not using Microsoft SQL Server, check out the documentation for your SQL flavour to see whether ROLLUP is supported.
The dbfiddle website can be accessed for free and without an account at:
https://dbfiddle.uk/
Make sure to use the SQL Server dialect and the AdventureWorks sample database to be able to follow along with these examples!
---------------------------------------------------
This is part of the From Excel to SQL playlist, available at:
• From Excel to SQL
Check out the previous video at:
• From Excel to SQL - Aggregations (GROUP BY)
...and the next video at:
• From Excel to SQL - Joins (JOIN)
The written version of this content is also available at:
https://billwallis.github.io/sql-lear...
---------------------------------------------------
CHAPTERS
00:00 dbfiddle
00:28 Intro
01:04 Recap on GROUP BY
04:05 Adding subtotals and grand totals (Excel)
04:50 Adding subtotals and grand totals (SQL)
06:57 Column order is significant
08:20 ROLLUP isn't in every SQL flavour
09:02 Wrap Up