Re: How to delete duplicate rows with sql
Posted in 1995
-S.POTHIREDDY (siva@hogpe.ho.att.com) wrote:
: Could any body tell me how to delete duplicate rows in a table. I was
: able to list the duplicate rows in table like this:
: Siva Pothireddy
Here's one solution:
select min(rowid) tmp_rowid from _tablename_ group by _key_fields_
into temp tmp_table with no log;
delete from _tablename_
where rowid not in
(select tmp_rowid from tmp_table);
Replace _tablename_ and _key_fields_ with appropriate names.
Catalin.
--
===========================================================================
Catalin Badea _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/ _/ _/_/_/
_/ _/ _/ _/ _/_/ _/
Senior Technical Architect _/ _/_/ _/ _/_/_/ _/ _/_/_/
_/ _/ _/ _/ _/ _/
Tecsys Inc. _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/_/
====== cat@tecsys.com =========== include system "disclaimer.4gh" ======