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 NameCount
from
(
select orderid, name
from #t
group by orderid, name
having count(*) > 1
) t
group by orderid
having count(*) = 1
drop table #t
Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Subscribe to my blog