Re: Help with duplicate records
From: Juanma Munoz <juanma_at_hgvh.es>
Date: Mon, 22 Jun 1992 20:02:48 GMT
Message-ID: <1992Jun22.200248.16146_at_hgvh.es>
Date: Mon, 22 Jun 1992 20:02:48 GMT
Message-ID: <1992Jun22.200248.16146_at_hgvh.es>
I think that the solution for your problem is :
delete from table_name a
where a.rowid < (select max(b.rowid)
from table_name b
where b.column1 = a.column1
and b.column2 = a.column2);
I proved this sentence for the next table (with duplicated rows) :
Table_name : << PROVA >>
CAMPO1 CAMPO2
---------- ----------
data1.1 data2.1 data1.1 data2.1 data1.2 data2.2 data1.3 data2.3 data1.3 data2.3 data1.3 data2.3 data1.4 data2.4 data1.4 data2.4 data1.4 data2.4 data1.4 data2.4 data1.5 data2.5 11 rows selected.
, and the result after execution of SQL script is :
delete from prova a
where a.rowid < (select max(b.rowid)
from prova b
where b.campo1 = a.campo1
and b.campo2 = a.campo2);
6 rows deleted.
SQL> select * from prova;
CAMPO1 CAMPO2
---------- ----------
data1.1 data2.1
data1.2 data2.2
data1.3 data2.3
data1.4 data2.4
data1.5 data2.5
SQL> spool off;
, I hope this post solutioned your problem.
Received on Mon Jun 22 1992 - 22:02:48 CEST
