i assume your data is like below then my query can give you what you expected
Employeeid 1 has both Swimming & Programming
Create table #EmployeeActivities
(
employeeid int,
ActivitiyId int
)
GO
insert into #EmployeeActivities
select 1,1571 union all -- let's assume Swimming
select 1,1625 union all -- let's assume Programming
select 2,1572 union all --let's assume Football
select 2,1571 -- let's assume Swimming
GO
SELECT EmployeeId
FROM #EmployeeActivities a
where ActivitiyId in (1571,1572)
and EXISTS(select top 1 1 from #EmployeeActivities b where a.EmployeeId=b.EmployeeId and b.ActivitiyId= 1625)
Thanks
Saravana Kumar C
No comments:
Post a Comment