I have a table with the following diagram
(Id(int PK),EmployeeId(int),DepartmentId(int),IsSelfAccessToDepartment(bit))
this table may contain the following entries
(1,101,21,1)
(2,101,22,0)
(3,102,21,1)
(4,103,21,1)
(5,103,22,0)
I want to get only those employee IDs where IsSelfAccessToDepartment = 1, if the same employee ID has another entry, where IsSelfAccessToDepartment = 0, in this case this line should not be retrieved.
The problem is that I want to get this information without using any subqueries and joins, because it will create performance problems since this table will have millions of records.
source
share