Skip to content

Instantly share code, notes, and snippets.

@shrawanx
Created June 15, 2018 03:02
Show Gist options
  • Save shrawanx/0c26074f31592760c27698196fad1ece to your computer and use it in GitHub Desktop.
Save shrawanx/0c26074f31592760c27698196fad1ece to your computer and use it in GitHub Desktop.
rollup and cube operations
--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