Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Sample table: emp_department

DPT_CODE DPT_NAME        DPT_ALLOTMENT
-------- --------------- -------------
      57 IT                      65000
      63 Finance                 15000
      47 HR                     240000
      27 RD                      55000
      89 QC                      75000


Sample table : emp_details

EMP_IDNO EMP_FNAME       EMP_LNAME         EMP_DEPT
--------- --------------- --------------- ----------
   127323 Michale         Robbin                  57
   526689 Carlos          Snares                  63
   843795 Enric           Dosio                   57
   328717 Jhon            Snares                  63
   444527 Joseph          Dosni                   47
   659831 Zanifer         Emily                   47
   847674 Kuleswar        Sitaraman               57
   748681 Henrey          Gabriel                 47
   555935 Alex            Manuel                  57
   539569 George          Mardy                   27
   733843 Mario           Saule                   63
   631548 Alan            Snappy                  27
   839139 Maria           Foster                  57


What I have tried:

SQL
SELECT emp_department.dpt_name  
  FROM emp_details   
     INNER JOIN emp_department  
       ON emp_dept = dpt_code...
Posted
Updated 30-Mar-17 9:39am
v2

1 solution

This is your homework, so I'll not give you the code!
But start by finding out haw many departments have three or more employees - that's a simple GROUP BY on your emp_details table.
When you have that, use a JOIN onto your emp_department table to get the department name.
 
Share this answer
 
Comments
MarkNopfler 30-Mar-17 15:43pm    
SELECT emp_department.dpt_name
FROM emp_details
INNER JOIN emp_department
ON emp_dept =dpt_code
GROUP BY emp_department.dpt_name
HAVING COUNT(*) > 2; ?
MarkNopfler 30-Mar-17 15:43pm    
thank you so much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900