Skip to content

Instantly share code, notes, and snippets.

@niisar
Created May 20, 2014 19:57
Show Gist options
  • Save niisar/b1d1ab70b1c0af57c877 to your computer and use it in GitHub Desktop.
Save niisar/b1d1ab70b1c0af57c877 to your computer and use it in GitHub Desktop.
grouping sets example
select SURVEY_YEAR,
candybar_name,
gender,
overall_rating,
sum(number_bars_consumed) as total_bars_consumed
from CANDYBAR_CONSUMPTION_DATA
group by grouping sets (
(SURVEY_YEAR,candybar_name,gender,OVERALL_RATING),
(SURVEY_YEAR,candybar_name,gender),
(SURVEY_YEAR,candybar_name),
(SURVEY_YEAR),
()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment