+ 1

How to delete duplicate records in SQL

delete from EmpDup where EmpID in(select EmpID from EmpDup group by EmpId having count(*) >1)

13th Dec 2016, 12:07 PM
Akwin Lopez
Akwin Lopez - avatar
2 Respuestas
+ 2
That'll delete all the repeated occurrences, not leave a unique record for each one of them. Is this what you wanted?
14th Feb 2017, 6:42 AM
Álvaro
0
Use ROWID.... delete from EmpDup where rowid in (select max(rowid) from EmpDup group by EmpId having count(*) >1);
26th Feb 2017, 11:42 AM
Ashish Shakya