Skip to content
SQLSimplified
Data AnalystQuestion 48 of 57

Generating Subtotals with ROLLUP

Problem

The retail lead wants an aggregated sales report that shows total sales by customer, and a grand total of all sales at the bottom of the table. Write a query that outputs concept with the value: "GROUP BY ROLLUP generates hierarchical subtotals and grand totals in a single query by moving from right to left across grouping columns."

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution