当然办法是最苯的了
create table #t(a int,b int,c int)
insert into #t select 1,1,1
union all select 1,1,2
union all select 3,1,2
union all select 3,1,2
union all select 4,3,2
union all select 4,4,2
union all select 4,5,2
union all select 4,6,2
declare t_cursor cursor
for select a,b,c from #t order by a
declare @a int,@b int,@c int
declare @test table(a int,b int,c int)
open t_cursor
fetch next from t_cursor into @a,@b,@c
while @@fetch_status=0
begin
if not exists(select 1 from @test where a=@a)
insert into @test select @a,@b,@c
fetch next from t_cursor into @a,@b,@c
end
select * from @test
close t_cursor
deallocate t_cursor