Topic: Inclusion & exclusions with in the same table Posted: 07 Feb 2014 at 10:47am
Hello ,
I have data something like this, I only need to include all employees who has access to dept 50 and excludes employees who have access to department 100
Employee ID Line Department ID
100 1 350
100 2 150
100 3 250
100 4 50
100 5 450
101 1 50
101 2 100
101 3 150
101 4 250
my data looks something like this
100 1 350
100 2 150
100 3 250
100 4 50
100 5 450
101 employee has access to both 100 & 50 so he has to be eliminated.
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Posted: 10 Feb 2014 at 5:28am
create a command, something like:
select distinct employeeID
from table incd
LEFT join (select employeeID from table excl
where excl.dept = 100) sub
on incd.employeeID = sub.employeeID
where incd.dept = 50 and sub.employeeID is null
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum