Exercise

Generate custom groupings with GROUPING SETS

The GROUPING SETS operator allows us to define the specific aggregation levels we desire.

In this scenario, management would like to see something similar to a ROLLUP but without quite as much information. Instead of showing every level of aggregation in the hierarchy, management would like to see three levels: grand totals; by year; and by year, quarter, and month.

Instructions

100 XP
  • Fill out the GROUP BY segment using GROUPING SETS. We want to see:
  • One row for each combination of year, quarter, and month (in that hierarchical order)
  • One row for each year
  • One row with grand totals (that is, a blank group)