declare @t table(a int,b int,c char(1)) insert into @t select 1,1,'+' insert into @t select 1,1,'-' insert into @t select 2,1,'+' insert into @t select 2,1,'+'select count(*) as n from @t a where not exists(select 1 from @t where a=a.a and b=a.b and c!=a.c)/* n ---- 2 */
insert into @t select 1,1,'+'
insert into @t select 1,1,'-'
insert into @t select 2,1,'+'
insert into @t select 2,1,'+'select
count(*) as n
from
@t a
where
not exists(select 1 from @t where a=a.a and b=a.b and c!=a.c)/*
n
----
2
*/