朕自己着磨出来的在SQL中删复复数据的SQL

朕自己着磨出来的在SQL中删复复数据的SQL

 

 

delete from     mytable where id in(
        
       select max(id) from 
       
    ( select * from mytable where goods_id in
     (select goods_id from mytable
     where  CONVERT(varchar(10),createDate,111)='2011/12/17'
    group by goods_id having COUNT(goods_id)>1  )
    and CONVERT(varchar(10),createDate,111)='2011/12/17'
   
    )as temptb
   
    group by goods_id
   
   
    )

你可能感兴趣的:(sql)