Last active
February 28, 2018 18:15
-
-
Save sfkeller/511418aa3f408dc335be92a8fbbaa73f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
CASE WHEN GROUPING(movie.genre) = 1 then 'All Genres' else movie.genre end as Genre, | |
CASE WHEN GROUPING(customer.gender) = 1 then 'All Genders' else customer.gender end as Gender, | |
sum(sales.quantity) AS Quantity | |
FROM factsales sales, dimmovie movie, dimcustomer customer | |
WHERE sales.movieId = movie.movieId | |
AND sales.custID = customer.custID | |
GROUP BY CUBE(movie.genre, customer.gender); | |
/* | |
"Action";"f";17 | |
"Action";"m";25 | |
"Action";"All Genders";42 | |
"Non-Action";"f";27 | |
"Non-Action";"m";15 | |
"Non-Action";"All Genders";42 | |
"All Genres";"All Genders";84 | |
"All Genres";"f";44 | |
"All Genres";"m";40 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment