Follow us: Connect on YouTube Connect on YouTube Connect on YouTube


Tuesday, 10 May 2016

Query to Finding and Deleting Duplicate Rows

The following statement will find and display all duplicate rows in a table, except the row with the maximum rowid:

FROM <tableA> a
WHERE rowid  <>  (SELECT max(rowid)
FROM <tableB> b
WHERE a.<column1> = b.<column1>
AND a.<column2> = b.<column2> -- make sure all columns are compared
AND a.<column3> = b.<column3>;

Note:  Duplicate rows which contain only NULL values will not be identified by above statement.
Share this article :


Post a Comment