Here's what I came up with:create table #t (orderid int, name char(1), workid int)insert into #t values(100,'A', 1001)insert into #t values(100,'A', 1002)insert into #t values(101,'A', 1003)insert into #t values(101,'B', 1004)insert into #t values(101,'A', 1005)insert into #t values(101,'B', 1006)select orderid, count(*) as NameCountfrom( select orderid, name from #t group by orderid, name having count(*) > 1) tgroup by orderidhaving count(*) = 1drop table #t
Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog