Skip to content

Commit 405cead

Browse files
authored
Create SQL Exercises: Find the names of departments where more than two employees are working
1 parent 970dd6a commit 405cead

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
https://www.w3resource.com/sql-exercises/sql-joins-exercise-29.php
2+
3+
SQL JOINS: Exercise-29 with Solution
4+
From the following tables write a SQL query to find the names of departments where more than two employees are working. Return dpt_name.
5+
6+
Sample table:emp_department
7+
DPT_CODE DPT_NAME DPT_ALLOTMENT
8+
-------- --------------- -------------
9+
57 IT 65000
10+
63 Finance 15000
11+
47 HR 240000
12+
27 RD 55000
13+
89 QC 75000
14+
15+
Sample table: emp_details
16+
EMP_IDNO EMP_FNAME EMP_LNAME EMP_DEPT
17+
--------- --------------- --------------- ----------
18+
127323 Michale Robbin 57
19+
526689 Carlos Snares 63
20+
843795 Enric Dosio 57
21+
328717 Jhon Snares 63
22+
444527 Joseph Dosni 47
23+
659831 Zanifer Emily 47
24+
847674 Kuleswar Sitaraman 57
25+
748681 Henrey Gabriel 47
26+
555935 Alex Manuel 57
27+
539569 George Mardy 27
28+
733843 Mario Saule 63
29+
631548 Alan Snappy 27
30+
839139 Maria Foster 57
31+
32+
33+
select b.dpt_name
34+
from emp_details as a
35+
join emp_department as b on b.dpt_code=a.emp_dept
36+
group by b.dpt_name
37+
having count(*) > 2
38+
;
39+

0 commit comments

Comments
 (0)