declare @table1 table (ptid int,ptcode varchar(1))
insert into @table1
select 1,'a' union all
select 1,'b' union all
select 1,'c' union all
select 1,'d' union all
select 1,'e' union all
select 2,'a' union all
select 2,'b' union ALL
select 2,'c' union ALL
select 3,'a' union all
select 3,'e' union all
select 4,'b' union all
select 4,'e'
select ptid from @table1
where ptcode in('a','b','c') group by ptid having count(1)>=3