Is there any query which will delete exactly one of the duplicate rows in a table and retain only one ?
Query to delete one of the duplicate rows
Collapse
X
-
Tags: None
-
DELETE FROM <TABLE_NAME> WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM <TABLE_NAME> GROUP BY <COLUMN_NAME> HAVING COUNT(COLUMN_NA ME) >= 1)
Say you have following data:
Table emp_det
EMPID ENAME
101 A
101 A
102 B
102 B
Then the below query will delete the duplicate records from emp_det table.
DELETE FROM emp_det WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM emp_det GROUP BY empid HAVING COUNT(empid) >= 1)Comment
-
Comment