比如
col1 col2 col3
 1    a    x
 2    b    y
 3    b    y
 4    c    z
 5    c    z
如果有多条col2和col3相同的数据的话只保留第一条数据。
col1 col2 col3
 1    a    x
 2    b    y
 4    c    z

解决方案 »

  1.   

    delete a from table1 a where ID not in(select min(ID) from table1 where Col3=a.Col3 and COl2=a.Col2)
      

  2.   

    delete a from table1 a where ID not in(select max (ID) from table1 where Col3=a.Col3 and COl2=a.Col2)delete a from table1 a where ID not in(select top 1 ID from table1 where Col3=a.Col3 and COl2=a.Col2)
    delete a from table1 a where ID not in(select min(ID) from table1 where Col3=a.Col3 and COl2=a.Col2)
     任选