select * from tb t where exists(select 1 from product=t.product and [order]<>t.[order])
select * from tb t where (select count(*) from tb where product = t.product) > 1
select * from table1 T where product in ( select Product from Table1 group by product having count(order)>1 )
select * from tb t where exists(select 1 from product=t.product and [order]<>t.[order])
create table #table1(product nvarchar(5), [order] nvarchar(5)) insert #table1 select 'p1','o1' union all select 'p2','o1' union all select 'p4','o2' union all select 'p5','o2' union all select 'p6','o3' union all select 'p7','o3' union all select 'p7','o4'select * from #table1 as t1 where exists(select 1 from #table1 as t2 where t1.product=t2.product and t1.[order]<>t2.[order])
select * from table1 where product in(select product from table1 group by product having count(1)>1)
select *
from tb t
where exists(select 1 from product=t.product and [order]<>t.[order])
select *
from tb t
where (select count(*) from tb where product = t.product) > 1
select * from table1 T
where product in (
select Product from Table1
group by product
having count(order)>1 )
create table #table1(product nvarchar(5), [order] nvarchar(5))
insert #table1
select 'p1','o1' union all
select 'p2','o1' union all
select 'p4','o2' union all
select 'p5','o2' union all
select 'p6','o3' union all
select 'p7','o3' union all
select 'p7','o4'select * from #table1 as t1 where
exists(select 1 from #table1 as t2 where t1.product=t2.product and t1.[order]<>t2.[order])
select * from table1 where product in(select product from table1 group by product having count(1)>1)