select field2,min(field1) as field1 into #a from tablename group by field1   delete from tablename
insert tablename(field1,field2) select field1,fiedl2 from #a

解决方案 »

  1.   

    delete a
    from tablename a
    where 字段1  <>(select min(字段1)  from Tablename where 字段2=a.字段2)sql server
      

  2.   

    select 字段1,distinct 字段2 from 表名
      

  3.   

    字段1 a1,字段2 a2
    select min(a1) a1,a2 from caishui.test1 group by a2
      

  4.   

    Delete From TableName Where 字段1 Not In (Select First(字段1) From TableName Group By 字段2)
    在Access2000中通过。
    送分来!!!
      

  5.   

    sql server:
    delete a
    from tablename a
    where 字段1  <>(select min(字段1)  from Tablename where 字段2=a.字段2)
      

  6.   

    Poison(Poison) 兄的方法有点问题,select 字段1 group by 字段2肯定不对
    这样行吗?没试过
    delete from tablename 
    where 字段1 not in 
    (select a.字段1 form  
     (select distinct top 100 字段2,字段1 from tablename order by 字段2)as a)
      

  7.   

    if 1,2 or both are not the key or superkey, there must be some other conditions applying to the table which you did not mention here.
    therefore, no sufficient information.
      

  8.   

    So, my point is,
    for example, which records of 字段1 should be reserved and which should be deleted?????