Re: remove duplicates

  • From: Alisher Yuldashev <yuldashev@xxxxxxxxxxx>
  • To: barb.baker@xxxxxxxxx
  • Date: Wed, 28 Jul 2010 13:22:15 -0400

Barbara,

This will delete all duplicate rows with the minimal woe_sid
delete from woe_fact_barb where (woe_sid,wo_sid) in (select min(woe_sid),wo_sid from woe_fact_barb group by wo_sid);

This one is to delete the minimal woe_sid with wo_sid equal 177694790
delete from woe_fact_barb where wo_sid=177694790 and woe_sid = (select min(woe_sid) from woe_fact_barb where wo_sid=177694790);

Thanks,

Alisher Yuldashev
www.pythian.com



Barbara Baker wrote:
oracle 9.2.0.7 on linux
I have some duplicated records in a table (woe_fact_barb)
I cannot come up with the sql to remove these.  Can anyone help?
The only way to identify the duplicate is that there are 2 records with the same WO_SID.

   WOE_SID     WO_SID   INVC_AMT
---------- ---------- ----------
   1079559  177694790     7898.1
   1080085  177694790     7898.1
   1079589  177694810   24026.19
   1079663  177694810   24026.19
   1079567  177694858   17088.35
   1080135  177694858   17088.35

I've tried various combinations of sql sorta like this:

sql>delete from woe_fact_barb
  2  (select min(woe_sid)
  3  from woe_fact_barb )
  4  where wo_sid=177694790
  5  /

Nothing I've tried is close.
thanks for any help!
Barb

Other related posts: