select * from table
where id in (select id from table
where id in (1,2,4,5,6)
group by id
having count(id) > 5)
select * into #t from table where id in (1,2,4,5,6);
select * from table where id in (1,2,4,5,6) and (select count(distinct id) from #t)>5
没明白,是要么全查,要么不查么?