朕自己着磨出来的在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
   
   
    )

posted @ 2011-12-21 18:35  咸鱼公子  Views(204)  Comments(1Edit  收藏  举报