Skip to content

Commit 80b85fb

Browse files
authored
Update solutions.sql
1 parent 60c3d0b commit 80b85fb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

SQL Deep Dive/Grouping Sets/solutions.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ GROUP BY
1212
()
1313
)
1414
order by e.dept_no
15+
16+
17+
/*
18+
* Calculate the total average salary per department and the total using grouping sets
19+
* Database: Employees
20+
* Table: Employees
21+
*/
22+
select grouping(de.dept_no), de.dept_no, AVG(e.salary)
23+
FROM public.salaries as e
24+
JOIN public.dept_emp as de USING (emp_no)
25+
GROUP BY
26+
GROUPING SETS (
27+
(de.dept_no),
28+
()
29+
)
30+
order by de.dept_no

0 commit comments

Comments
 (0)