RE: Delete Duplicates

From: Jacqui Thompson <thompson_at_cc.und.ac.za>
Date: Tue, 15 Jun 1993 12:52:34 GMT
Message-ID: <thompson.2.740148754_at_cc.und.ac.za>


Hi there,

To delete duplicates from a table, there are columns that are duplicated, say col1, col2, col3:-

delete from tab A
where exists (select 1

               from   tab B
               where  A.col1 = B.col1  and
                      A.col2 = B.col2  and         } Add as many columns
                      A.col3 = B.col3  and         } as make up the dupl.
                      A.rowid > B.rowid)

This should get rid of duplicates, triplicates etc. while leaving one. For example if you had rows:

       A A B B C A A B  (where A is a row etc.)
     the result would be...
       A B C

Hope this is what you need.
Jacqui

|--------------------------------------------------------------------|

| *** Jacqueline J. Thompson |
| *** Oracle DBA & * University of Natal |
| Analyst Programmer * Computer Services Division |
| *** Tel: 031 - 8162471 * King George V Avenue |
| *** Fax: 031 - 8162125 * Durban, 4001 |
| *** Internet: thompson_at_cc.und.ac.za * South Africa |
|--------------------------------------------------------------------|
Received on Tue Jun 15 1993 - 14:52:34 CEST

Original text of this message