In MS SQL Server, using the following data, how do I find empIds that have dept 10 complete (=1) and no entry for dept 11?
deptId empId complete
10 3 1
11 3 0
10 4 1
10 5 1
11 5 0
12 5 1
10 6 1
10 7 1
11 7 0
This should return empIds 4 and 6.
Response:
the query is the list of employees that have dept 10 complete (=1)
the subquery is the list of employees that has entry for dept11.
With CTE: