v.18.14New Feature
WITH CUBE Modifier for GROUP BY in ClickHouse
TheWITH CUBEmodifier forGROUP BY(the alternative syntaxGROUP BY CUBE(...)is also available). #3172
Why it matters
This feature simplifies the generation of subtotals and totals across multiple dimensions in aggregation queries. It addresses the need for comprehensive multidimensional summaries, making it easier for users to produce detailed reports without manually specifying multiple grouping sets.How to use it
Users can apply the feature by adding theWITH CUBE modifier after the GROUP BY clause or by using the alternative syntax GROUP BY CUBE(...). For example:SELECT column1, column2, SUM(metric)
FROM table
GROUP BY column1, column2 WITH CUBEor
SELECT column1, column2, SUM(metric)
FROM table
GROUP BY CUBE(column1, column2)