I have an Employee table and another one EmployeeManager, I need to do a query to show all employees that are not managers and another one that shows all employees that are managers.
This is the first query:
SELECT E.EmployeeId, E.FirstName, E.LastName
FROM Employee E
INNER JOIN (SELECT a.EmployeeId,
(SELECT COUNT(*) FROM EmployeeManager b
WHERE a.EmployeeId = b.Managerid) IsManager
FROM EmployeeManager a) ER
ON E.EmployeeId = ER.EmployeeId
AND ER.IsManager = 0
Is there any better option? because I don't like at all.