Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to add this additional information, The total salary for each department,

ID: 3775635 • Letter: I

Question

I need to add this additional information, The total salary for each department, irrespective of job titles The total salary for every job, irrespective of the department The total for all salaries Order by department name and job ID.

To this query, select department_name, job_id, sum(A.salary)from employees a join departments d on(a.department_id = d.department_id) where a.department_id > 80 group by department_name, job_id order by d.department_name, job_id;

I think i am supposed to use the rollup or cube function.

Explanation / Answer

select department_name, job_id, sum(A.salary)from employees a join departments d on(a.department_id = d.department_id) where a.department_id > 80

group by ROLLUP( department_name, job_id order by d.department_name, job_id);

This will salary for every department, total salary for every job and totol of all salaries from right to left one by one and sum up all the salaries that are required in the problem.This is how rollup sums up all indivisual salaries.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote