数据表中查找重复数据并做删除操作

oracle 中测试成功

--找出表中的重复数据 select * from vav_groupbrand_casn where ccasn in ( select ccasn   from vav_groupbrand_casn group by ccasn  having count(*)>1  ) order by ccasn

--找出表中的重复数据 select * from vav_groupbrand_casn  a, vav_groupbrand_casn b where  a.cgroupbranid =b.cgroupbranid and a.ccasn=b.ccasn and a.ccreatedate>b.ccreatedate

--删除重复数据 delete from vav_groupbrand_casn a where rowid !=( select max(rowid)   from  vav_groupbrand_casn b  where a.cgroupbranid = b.cgroupbranid    and a.ccasn = b.ccasn    and a.ccreatedate > b.ccreatedate);

posted @ 2012-07-26 10:36  石 磊  阅读(288)  评论(0编辑  收藏  举报