-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup_cube.sql
More file actions
38 lines (32 loc) · 773 Bytes
/
rollup_cube.sql
File metadata and controls
38 lines (32 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Review the columns available in staff_div_reg view */
select
*
from
staff_div_reg
limit
10;
/* Select nubmer of employees by company_region and country */
select
company_region, country, count(*)
from
staff_div_reg
group by
company_region, country
order by
country, company_region
/* Use rollup operation on the group by clause to create hierarchical sums */
select
company_region, country, count(*)
from
staff_div_reg
group by
rollup (country, company_region)
order by
country, company_region
/* Use cube operation on the group by clause to create all possible combination of sets of grouping columns */
select
company_division, company_region, count(*)
from
staff_div_reg
group by
cube (company_division, company_region);