select identity(int,1,1) as NID,* into #temp
select a,b,c,d,e from #temp
where NID in(select min(NID) as NID from #temp group by a,b,c)
drop table #temp

解决方案 »

  1.   

    select identity(int,1,1) as ID,* into #tempselect a,b,c,d,e from #temp aa
    where ID in 
    (select min(ID) as ID from #temp bb 
       where  aa.a = bb.a and aa.b = bb.b and aa.c = bb.c)drop table #temp
      

  2.   

    就你题目上举的例:
    select distinct * from 表就你的题意:select identity(int,1,1) ID,* into #temp from 表select a,b,c,d,e from #temp aa where ID=(select min(ID) as ID from #temp where a = aa.a and b = aa.b and c=aa.c)drop table #temp
      

  3.   

    用临时表来处理:
    --将不重复的数据导入到临时表
    select distinct * into #temp from 表--删除原表数据
    truncate table 表--从临时表中导回数据
    insert into 表 select * from #temp--处理完成后删除临时表
    drop table #temp