Created
June 15, 2018 03:02
-
-
Save shrawanx/0c26074f31592760c27698196fad1ece to your computer and use it in GitHub Desktop.
rollup and cube operations
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
--ROLLUP AND CUBE OPERATIONS | |
select department_id , sum(salary) | |
from employees group by department_id | |
order by department_id; | |
select department_id ,job_id, sum(salary) | |
from employees group by department_id,job_id | |
order by department_id; | |
select department_id ,job_id, sum(salary) | |
from employees group by rollup(department_id,job_id) | |
order by department_id; | |
--cube First groups sub-group ie: sum of above two query | |
select department_id ,job_id, sum(salary) | |
from employees group by cube(department_id,job_id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment