CoderZone.org

Category: >> mySQL >> Remove Duplicates Bookmark and Share

<< lastnext >>

Snippet Name: Remove Duplicates

Description: remove duplicates in one pass at the table

Comment: First, you need to decide which fields constitute a duplicate, list these in each of the two 'group by' clauses, replacing fld1, fld2, etc.

Author: CoderZone
Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: February 28th, 2009

DELETE FROM tablename
WHERE ROWID IN (
   SELECT ROWID
   FROM test
   GROUP BY ROWID, fld1, fld2, fld3
   MINUS
   SELECT MIN(ROWID)
   FROM test
   GROUP BY fld1, fld2, fld3);
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 9