SQLAdvanced#aggregates

What is GROUP BY with ROLLUP?

ROLLUP adds super-aggregate subtotal rows to a GROUP BY result, producing per-group totals plus a grand total in a single query.

Example
SELECT region, city, SUM(total)
FROM sales
GROUP BY ROLLUP (region, city);
-- rows per city, per region, then overall total

Related Questions

1
SQLIntermediate#queries#performance

How do you paginate results efficiently?

Open
2
SQLBeginner#fundamentals

What are DDL, DML, DQL, DCL and TCL?

Open
3
SQLIntermediate#joins

What is the difference between a natural join and an equi join?

Open