Home » SQL & PL/SQL » SQL & PL/SQL » Delete the duplicate rows
Delete the duplicate rows [message #184384] Wed, 26 July 2006 06:51 Go to next message
guru_karnam
Messages: 142
Registered: May 2005
Senior Member
select empno from emp;
empno
------
1
1
1
2
2
3
3
3

For deleting duplicate rows

delete from emp where rowid not in(select max(rowid) from emp
group by empno);

I wonder how this works internally?



Re: Delete the duplicate rows [message #184387 is a reply to message #184384] Wed, 26 July 2006 06:56 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Urrr.....just like the query says?

Generate a list consisting of the maximum Rowid for each Empno in the table Emp, and then delete any record whose Rowid isn't on that list.

Previous Topic: Moving average
Next Topic: IN OUT BOOLEAN IN A PROCEDURE
Goto Forum:
  


Current Time: Tue Dec 06 12:10:12 CST 2016

Total time taken to generate the page: 0.12069 seconds