OLAP: CUBE operator 显示所选列中值的所有组合的聚合
ABC, A, AB, AC, BC, A, B, C
AB, A,B
Business intelligence
On-line analytical processing>> interactively analyze the data and to summarize and visualize it.-Aggregate data for a better overview
Count number of rentings for each customer
Average rating of movies for each genre and each country
-Produce pivot tables to present aggregation resultsSELECT country, genre, count(*)
FROM renting_extended
GROUP BY CUBE (country, genre)
ROLLUP 显示所选中列中值的某一层次结构的聚合
ABC, AB, A,SELECT country, genre, count(*)
FROM renting_extended
GROUP BY ROLLUP(country, genre);
--Levels of aggregation
Aggregation of each combination of country and genre
Aggregation of country code
Total aggregation
--Include more than 1 aggregation SELECT country, genry, count(*) AS n_rentals, count(rating) AS n_ratings
FROM renting_extended
GROUP BY ROLLUP( genre,country)
GROUP BY GROUPING SETs
SELECT country, genre, count(*)
FROM rentings_extended
GROUP BY GROUPING SETS ((country,genre), (country),(genre),());Columns names surrounded by parentheses represent one level of aggregation.
returns a UNION over several GROUP BY queries