GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 34 of 132    Print  
How do I eliminate the duplicate rows

  
Total Answers and Comments: 12 Last Update: November 04, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: j Lehew
 
Use the DISTINCT keyword right after SELECT... 
 
i.e. SELECT DISTINCT customername FROM customer

Above answer was rated as good by the following members:
ashaRane, jnegimail
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
March 26, 2005 14:18:07   #1  
AjayLebaka        

RE: How do I eliminate the duplicate rows
DELETE TableName WHERE rowid NOT IN ( SELECT MIN(rowid) FROM TableName GROUP BY ColumnName );
 
Is this answer useful? Yes | No
August 25, 2005 12:52:18   #2  
j Lehew        

RE: How do I eliminate the duplicate rows
Use the DISTINCT keyword right after SELECT...

i.e. SELECT DISTINCT customername FROM customer

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
October 20, 2005 11:07:42   #3  
purushgeek Member Since: October 2005   Contribution: 3    

RE: How do I eliminate the duplicate rows
SELECT * from emp where rowid<>(select max(rowid) from emp )
 
Is this answer useful? Yes | No
October 28, 2005 07:21:36   #4  
matloob hussain        

RE: How do I eliminate the duplicate rows

I don;t think the above will work

plese try the following

Delete from emp a where a.rowid > ( select min(rowid) from emp b

where a.empno b.empno group by empno)

Matloob Hussain


 
Is this answer useful? Yes | No
January 20, 2006 12:34:13   #5  
richardlonghill        

RE: How do I eliminate the duplicate rows

Hello

What you mean eliminate does it mean to delete the rows or to de-select the duplicate rows..

We can use either distinct or rowid to eliminate duplicate rows


 
Is this answer useful? Yes | No
April 06, 2006 17:39:13   #6  
Satish Kumar        

RE: How do I eliminate the duplicate rows

delete from <table name> a1 where a1.rowid > any (select rowid from <table name> a2 where a1.<col name> a2.<col name>;

This works....

Regards

Satish Kumar


 
Is this answer useful? Yes | No
July 31, 2006 08:46:00   #7  
anonymous        

RE: How do I eliminate the duplicate rows
Use distinct keyword.
 
Is this answer useful? Yes | No
December 07, 2006 02:36:22   #8  
NARENDRA        

RE: How do I eliminate the duplicate rows
DELETE FROM EMP E WHERE ROWID NOT IN(SELECT MIN(ROWID) FROM EMP M WHERE E.EMPNO M.EMPNO);
 
Is this answer useful? Yes | No
January 05, 2007 00:27:21   #9  
Ramu        

RE: How do I eliminate the duplicate rows

there are around 4 ways to eliminate duplicate records upto my knowledge.

the first preferable answer u have to say is :

delete from table_name where rowid not in (select min(rowid) from table_name group by column_name)

if the interviewer asks for another method: try this method.

1. create table_name_b as select distinct * from table_name_a;

2. drop table_name_a;

3. rename table_name_b as table_name_a;

Finished...

and the remaingin methods r confusing where as u will be stopped as soon as u say these 2 types ..

Thanx..


 
Is this answer useful? Yes | No
January 24, 2007 04:35:39   #10  
praveenkumarmitta Member Since: January 2007   Contribution: 1    

RE: How do I eliminate the duplicate rows
we can print duplicate rows from a table in the follwoing way.... select * from table_name where count(*) >1; it will display the duplicate rows...
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
  Page 1 of 2   « First    1    2    >     Last »  


 
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