0

Here are the schemas of given tables:

ProjectManager(ProjId, MgrId, StartDate, EndDate)
EmpProject(EmpId, ProjId, StartDate, EndDate)

In which "MgrId" is the same as "EmpId" just different naming. The question is to find the non-manager employee IDs who joined all the projects.

My thought is: 1. In table EmpProject, using "group by ProjId" to find EmpId which exists in all groups. 2. Then only select those empid that's not in ProjectManager.MgrId

Another thought is something similar to SQL Query to get common records

I've tried several ways but couldn't make progress. Any help would be appreciated, Thanks!

Community
  • 1
  • 1
Heresy
  • 23
  • 1
  • 4

1 Answers1

0

Try this quick query. Basically, this filters out all Non-Managers by checking if the employee id is not present in the ProjectManager table

SELECT * 
FROM EmpProject
WHERE EmpId NOT IN (SELECT MgrId FROM ProjectManager)