My Table is
+-----+----+----+------+
|EmpID|Name|Dept|Deptno|
+-----+----+----+------+
|1 |Abc |xyz |10 |
|1 |Abc |xyz |10 |
|2 |Def |pqr |20 |
+-----+----+----+------+
I want the output table as
+-----+----+----+------+
|EmpID|Name|Dept|Deptno|
+-----+----+----+------+
|1 |Abc |xyz |10 |
|2 |Def |pqr |20 |
+-----+----+----+------+
Conditions:
- Don't Use window functions.
- Table doesn't have any keys.
- Don't Use Temporary Tables.
I tried a Query:
delete from table_name where EmpId IN (
select EmpID from table_name group by EmpId,Name,Email,Deptno having count(*)>1 )
But, this query deletes all the rows which are having count > 1. But, I trying to delete the duplicate rows except one