Given the sample data below. How could I get a list of employee ids by project excluding the employees' managers? I've tried many versions of sub-queries and can remove all managers (employees with no direct reports) but that's not right.
emp_id project_num
----- --------
e1 1
e2 1
e3 1
e5 4
e6 4
e7 4
Employee table:
emp_id mgr_id
------ ------
e1 e3
e2 e9
e3 e8 (mgr of e1 also on proj 1)
e5 e4
e6 e0 (mgr of e7 also on proj 4)
e7 e6
Result example:
1 | e1
1 | e2
4 | e5
4 | e7
Project 1 excludes e3 and project 4 excludes e6 because they are managers of employees on those same projects.
NOT EXISTSwork here? - Larnu