INTERVIEW QUESTIONS
ORACLE
SQL IN ORACLE
DETAILS
Question: table name stud,a mark 23,b mark 87,c mark 75,d mark 34; write the query to find 2nd highest mark in stud table?
Answer: To find the nth big earner:
select mark from stud a where n=select count(distinct(mark)) from stud b where b.mark >= a.mark)
|
Question:
table name stud,a mark 23,b mark 87,c mark 75,d mark 34; write the query to find 2nd highest mark in stud table?
Answer:
To find the nth big earner:
select mark from stud a where n=select count(distinct(mark)) from stud b where b.mark >= a.mark) Source: CoolInterview.com
Answered by: Gokulnath Bapoo | Date: 8/18/2008
| Contact Gokulnath Bapoo
select * from (select marks from stud oder by desc marks) where rownum=2; Source: CoolInterview.com
Answered by: Ajaz Ahmad Kumar | Date: 8/19/2008
| Contact Ajaz Ahmad Kumar
select mark from student where mark=(select max(mark) from student where mark <> (select max(mark) from student)); Source: CoolInterview.com
Answered by: Josna | Date: 10/21/2008
| Contact Josna
SELECT * FROM( SELECT marks, RANK() OVER (ORDER BY SAL DESC) RANK FROM EMP) WHERE RANK=2; Source: CoolInterview.com
Answered by: Divya | Date: 12/25/2008
| Contact Divya
1. SELECT mark from (SELECT mark,rownum rn FROM stud ORDER By mark DESC) WHERE rn=2;
2.SELECT mark FROM stud WHERE MAX(mark)<(SELECT MAX(mark) FROM stud); Source: CoolInterview.com
Answered by: Samir Kumar Sahoo | Date: 1/22/2009
| Contact Samir Kumar Sahoo
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|