Deleting Duplicates with SQL
Posted 2005 Aug 19
Deleting duplicate data in a database is a very common endeavor, especially when dealing with legacy databases and applications. I found this little gem and wanted to share:
- even better - doesn’t require a CURSOR.
<pre><code>
delete from employee
where (rowid, empssn) not in
(select min(rowid), empssn from employee group by empssn);
</code>
It’s simple and generally applicable and