Skip to content

Instantly share code, notes, and snippets.

@davidfetter
Created January 2, 2014 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfetter/8223770 to your computer and use it in GitHub Desktop.
Save davidfetter/8223770 to your computer and use it in GitHub Desktop.
GROUPING SETS
ROLLUP
SELECT count(a), sum(b), count(c) FROM table1 GROUP BY ROLLUP(a,b,c);
Grouping order:
GROUP BY (a,b,c)
GROUP BY (a,b)
GROUP BY (a)
GROUP BY ()
1) Add a new member for holding the number of GROUPING SETS. For ROLLUP, this will be equal to number of grouping columns + 1. <--a new member of what?
2) Currently, There is a AggStatePerGroupData GROUP per aggregate. This will be changed to a AggStatePerGroupData per GROUPING SET per GROUP pe Aggregate. This means that the number of AggStatePerGroupData instances for a query will be number 0f aggregates * number of grouping sets. Number of grouping sets is number of grouping columns + 1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment