|
发表于 2020-6-23 19:00:01
|
显示全部楼层
declare @t table(A varchar(4),B int)
insert into @t select '0001',1
insert into @t select '0001',2
insert into @t select '0001',3
insert into @t select '0001',4
insert into @t select '0001',5
insert into @t select '0001',6
insert into @t select '0001',7
insert into @t select '0001',8
insert into @t select '0001',9
insert into @t select '0001',10
insert into @t select '0001',11
insert into @t select '0001',12
insert into @t select '0002',10
insert into @t select '0003',1
insert into @t select '0003',2
insert into @t select '0003',3
insert into @t select '0003',4
insert into @t select '0003',5
insert into @t select '0003',6
insert into @t select '0003',7
insert into @t select '0003',8
insert into @t select '0003',9
insert into @t select '0003',10
insert into @t select '0003',11
insert into @t select '0003',12
select t.* from @t t where not exists(select 1 from @t where A=t.A and B!=t.B)
/*
A B
---- -----------
0002 10
*/ |
|