hi
hope this helps
i took into account ALL CIID 's will be different
create data script
drop table if exists #Temp
create table #Temp ( Date1 date, CIID int , EmpID int , EmpName varchar(10), EmpRole varchar(10) , EventID int , ProductID int )
insert into #Temp select '2022-12-31', 7810 , 8485 , 'sam', 'teacher' , 5662 , 35
insert into #Temp select '2022-12-31', 7810 , 8485 , 'sam', 'teacher' , 5690 , 35
insert into #Temp select '2022-10-31', 890 , 2100 , 'joe', 'doctor' , 2241 , 80
insert into #Temp select '2022-10-31', 521 , 2100 , 'joe', 'doctor' , 2241 , 80
insert into #Temp select '2022-10-31', 660 , 2100 , 'joe', 'doctor' , 2241 , 80
insert into #Temp select '2022-10-31', 255 , 2100 , 'joe', 'doctor' , 2241 , 80
insert into #Temp select '2022-10-31', 359 , 2100 , 'joe', 'doctor' , 2241 , 80
; with cteEventID as (select rank() OVER(partition by empid order by EventID) as rn, * from #Temp)
, cteCIID as (select empid , CASE WHEN count(distinct CIID)= count(CIID) THEN 1 ELSE 0 END as CIID_distinct from cteEventID where rn =1 group by empid )
select
b.*
from
cteCIID a
join
cteEventID b
on a.EmpID = b.EmpID
where
b.rn =1 and a.CIID_distinct = 1