v.18.12New Feature
New WITH ROLLUP Modifier for GROUP BY
NewWITH ROLLUPmodifier forGROUP BY(alternative syntax:GROUP BY ROLLUP(...)). #2948
Why it matters
This feature enables users to generate subtotals and grand totals in query results by performing hierarchical rollup aggregations automatically. It simplifies the process of obtaining aggregated summary data across multiple grouping levels without writing complex union queries.How to use it
To use this feature, add theWITH ROLLUP modifier after the GROUP BY clause in your SQL query. Alternatively, you can use the syntax GROUP BY ROLLUP(column1, column2, ...). For example:SELECT column1, column2,<br> SUM(measure) FROM table<br>GROUP BY column1, column2 WITH ROLLUPor
SELECT column1, column2,<br> SUM(measure) FROM table<br>GROUP BY ROLLUP(column1, column2)