记录相同指的是a,b 都相同?select a,max(b) into #tmp from table1 group by a
truncate table table1
insert into table1 select * from #tmp

解决方案 »

  1.   

    如果算a,b都相同的记录才算相同记录的话
    select distinct * from table1就可以了
      

  2.   

    比例表jb_tab
    lsh    zp  
     1     (大小不固定的)
     1
     2
     2
     3
     3
     3怎么样删除一个1,一个2 二个3 (假设有很多相同的记录)
      

  3.   

    给你一个例子,希望对你有启发:如表:T3
           
            a       b               c
    1 2          1.02      --重复    随机器取其中一条数据
    2 3          3.3       
    3 4          5         
    1 2          1.05      --重复
    4 5          6         select a,b 
    ,(select top 1 c from T3 where a = d.a and b = d.b order by newid()) as c
    from T3 d
    group by a,b  --a,b 组合分组结果:
    1 2          1.05      
    2 3          3.3       
    3 4          5         
    4 5          6         
      

  4.   

    若a,b都相同的话,那:select distinct a,b from 表若只是过滤a相同,b 任何一条的话:select c.a,(select top 1 b from 表 where a=c.a) as b from 表 as c group by c.a
      

  5.   

    有照片字段怎么办啊不能使用DISTINCT
      

  6.   


    比例表jb_tab
    lsh    zp  
     1     (大小不固定的)
     1
     2
     2
     3
     3
     3怎么样删除一个1,一个2 二个3 (假设有很多相同的记录)
    select identity(int) as newidd,* into #t from jb_tabtruncate table jb_tabinsert into jb_tab
    select lsh,zp from #t a 
                 where not exists (select 1 from #t where lsh=a.lsh and newidd>a.newidd)