Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) departmanet/job
- select department_name, job_title, null, max(salary), sum(salary)
- from employees e join jobs using (job_id) join departments using (department_id)
- group by department_name, job_title
- union all
- select null, job_title, e.manager_id, max(salary), sum(salary)
- from employees e join jobs using (job_id) join departments using (department_id)
- group by job_title,e.manager_id
- union all
- select null, null, null, max(salary), sum(salary)
- from employees e join jobs using (job_id) join departments using (department_id);
- SELECT department_id, TO_CHAR(hire_date, 'yyyy'), SUM(salary)
- FROM employees
- WHERE department_id < 50
- GROUP BY grouping sets((department_id,TO_CHAR(hire_date, 'yyyy')),(department_id));
- R C GS
- 1) Cate criterii folosesc ptr gen grupuri ? (c1,c2,.....,cn)
- toate criterrile posibile(2^n) => cube
- n+1 criterii (forma triunghiluara) rollup (intotdeauna primul criteriu e folosit)
- GS (G Sets) - definesti tu criterrile definite pt generarea coloanelor
- Rollup simulat cu GS
- Rollup(c1,c2,c3) => Grouping Sets((c1,c2,c3),(c1,c2),(c1),());
- select department_name, job_title, e.manager_id, max(salary), sum(salary) ,
- grouping(department_name),grouping(job_title),grouping(e.manager_id)
- from employees e join jobs using (job_id) join departments using (department_id)
- group by grouping sets((department_name, job_title),(job_title,e.manager_id),());
- select department_name,job_title,avg(salary), count(*)
- from employees e full join departments d on(e.department_id = d.department_id)
- join jobs j on (e.job_id = j.job_id)
- group by cube(department_name,job_title);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement