Re: removing duplicates rows

From: Andy Hardy <aph_at_ahardy.demon.co.uk>
Date: Fri, 25 Jun 1999 10:08:05 +0100
Message-ID: <f1fF$MA1b0c3EwkN_at_ahardy.demon.co.uk>


In article <gjAc3.5747$d5.725031_at_news21b.ispnews.com>, al <asalvado_at_ev1.net> writes
>If a tables rows are accidently duplicated, how do you remove duplicates?
>
>1st you can count the rows, and then use this count in the following SQL:
>DELETE: FROM table
>WHERE rownum < ( (row_count/2) + 1);
>
>This works only if you duplicated the rows all at once. What's the proper
>way of doing it?
>
>Thanks.
>
>
Try:

delete from my_table mt1
where rowid >

        (select min(rowid) from my_table mt2
          where mt2.my_pk = mt1.my_pk
        )

;

Andy

-- 
Andy Hardy. PGP key available on request
===============================================================
Received on Fri Jun 25 1999 - 11:08:05 CEST

Original text of this message