GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 75 of 138    Print  
1. How to delete a duplicate records in a table without using rowid?

2. What is the use of Connect by clause?

3. What is the use of Connect by clause?

4. How to display "Experience of employee"?E.g. 3 years 4 months 19 days?

5.What is select statement to spell out SALARY?(Query should work upto 5 million)

6. Why output give error message when i write select stmt, ROWNUM=2 in where clause.?

7. what is merging?

8.How to delete set of records at a time where all the records having same values , except the Rowid differs?

9. What is data merging, data cleansing, sampling?

10.How do you select multiple objects during merging the files?

  
Total Answers and Comments: 9 Last Update: August 06, 2007     Asked by: varadarajan 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 08, 2006 01:26:53   #1  
csr21 Member Since: August 2006   Contribution: 7    

RE: 1] How to delete a duplicate records in a table wi...

8]how to delete set of records at a time where all the records having same values , except the Rowid differs?

delete from testsal where rowid in
(select min(rowid) from testsal group by grade
having count(*)>1);


 
Is this answer useful? Yes | No
September 08, 2006 01:33:53   #2  
csr21 Member Since: August 2006   Contribution: 7    

RE: 1] How to delete a duplicate records in a table wi...

6] Why output give error message when i write select stmt, ROWNUM=2 in where clause.?

Reply : ROWNUM will always work for < or <= only, neither for = nor for > nor for >= as ROWNUM always start giving the rows of output result from 1 irrespective of the rownum values in a table. So, when u write ROWNUM=2 for any statement, query will retrive some records say row 'n'  and give it a value as ROWNUM= "1" , thats why it will never give any result for ROWNUM=2.

I hope i m able to explain the concept of rownum, but still if there is any confusion, feel free to ask further


 
Is this answer useful? Yes | No
October 03, 2006 03:58:57   #3  
MOHIT SRIVASTAVA        

RE: 1] How to delete a duplicate records in a table wi...

can you explain by giving some example

Regards

Mohit


 
Is this answer useful? Yes | No
October 04, 2006 03:12:53   #4  
chitra        

RE: 1] How to delete a duplicate records in a table wi...

Q:) Why output give error message when i write select stmt, ROWNUM=2 in where clause ?

Reply:) Hi Mohit, U try to  login thru scott username and lets take table "DEPT" for example. I hope u must be having this table . For eg- it contains total 4 rows.u run the query in the following sequence, u will come to know about the difference and the reason why ROWNUM=2 dint work :

a) select rownum,a.* from dept a;

b) select rownum,a.* from dept a where rownum<3;

c) select rownum,a.* from dept a where rownum=3;

got some idea ??????????

look, when query (b) is run, it will return 2 rows and save them as in output buffer for eg and assign them rownum as 1,2,3,......

but when query (c) is run,it should return the row having rownum=3 according to you,but what happened is that it also tries to return some rows and save them and assigns the returned result as rownum=1 , thats why it can never return any rows for rownum=3 or rownum>3 .

i hope this will clear your doubt ,but if there is still any confusion, feel free to ask .


 
Is this answer useful? Yes | No
October 04, 2006 06:04:57   #5  
chitra        

RE: 1] How to delete a duplicate records in a table wi...

Q:) Displaying Experience  eg- 5 years 7 months 9 days?

Reply:) I've tried it and I m able to do it for years and months only , not for days . Here is the query for this

select trunc(months_between(end_date,start_date)/12) || ' years ' ||
 trunc(trunc(months_between(end_date,start_date))-
trunc((months_between(end_date,start_date)/12))*12)||' months '
 experience,start_date,end_date,employee_id from job_history


 
Is this answer useful? Yes | No
October 30, 2006 00:29:03   #6  
S.Senthil Kumar        

RE: 1] Connect By Cause
CONNECT BY specifies the relationship between parent rows and child rows of the hierarchy. In a hierarchical query, one expression in condition must be qualified with the PRIOR operator to refer to the parent row. For example,... PRIOR expr = expror... expr = PRIOR expr
 
Is this answer useful? Yes | No
November 08, 2006 03:20:15   #7  
seema        

Re:How to display "Experience of employee"?e.g. 3 years 4 months 19 days?

You can follow this example-

 select floor((trunc(sysdate)  - to_date('01-JAN-01'))/365)  years,
floor(mod((trunc(sysdate)- to_date('01-JAN-01')),365)/30 ) months ,
mod(mod((trunc(sysdate)- to_date('01-JAN-01')),365),30) days from dual;


 
Is this answer useful? Yes | No
December 08, 2006 02:06:19   #8  
appu        

RE: 1. How to delete a duplicate records in a table wi...

delete from tablename

 where column_name=(select max(column_name) from tablename group by column_names

having count(column1||column2>1);

eg:tablename:student(name,id,age,addr)

Sql> delete from student

where id=(select max(id) from student group by id

having count(id||name)>1);


 
Is this answer useful? Yes | No
August 06, 2007 03:48:05   #9  
Bhupendra        

RE: 1. How to delete a duplicate records in a table wi...

I have to modify this query because every month doesn't have exactly 30 days.
so in this case the number of days displayed is wrong. We have to take it as
30.42 (which is avg of number of days in a month).

Updated version is as follow


select floor((trunc(sysdate)-to_date('01-jan-01'))/365)||'years' ,floor(mod((trunc(sysdate)-to_date('01-jan-01')),365)/30)||'months',trunc(mod(mod((trunc(sysdate)-to_date('01-jan-01')),365),30.42))||'days'
from dual


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape