GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 77 of 171    Print  
how to delete set of records at a time where all the records having same values , except the Rowid differs?

  
Total Answers and Comments: 3 Last Update: December 04, 2006     Asked by: myquery 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 16, 2006 08:43:16   #1  
Abhishek Gupta        

RE: how to delete set of records at a time where all t...

yes you can delete the duplicate records with the help of a sql query as follows

delete from table_name where rowid not in(select max(rowid) from table_name group by field_name)

in this way only rowid with distinct values will remain and the rest will be removed.I hope it will help you out.


 
Is this answer useful? Yes | No
August 23, 2006 19:47:21   #2  
Anjali        

RE: how to delete set of records at a time where all t...

Abhishek I think in the group by clause u need to add all the field names so as to make sure the records are exactly same.

Anjali


 
Is this answer useful? Yes | No
December 04, 2006 14:14:24   #3  
rampratap409 Member Since: September 2006   Contribution: 111    

RE: how to delete set of records at a time where all t...

use this query:

delete from emp e

where rowid <> ( select max(rowid) from emp

where ename e.ename );


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape