how to get second highest sal of emp table

Answer Posted / prabhudatta barick

--IN ORDER TO FIND THE NTH HIGHEST SALARY,
--WE JUST FIND THE SALARY THAT HAS EXACTLY N-1 SALARIES
GREATER THAN ITSELF---

--This is correlated subquery--
select empno,
ename,
sal
from scott.emp e
where &n-1=(select count(distinct b.sal) from scott.emp b
where b.sal>e.sal);

To get second highest salary put n value 2.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the use of record option in exp command.

531


I am using an Oracle 8i Database my data contains Clob data. I am using toad version 7.6 i am able to get the data in toad but unable to extract the data in excel.when trying to extract the data into the excel the toad error says out of memory. Can any body please help me to extract the data through the same toad version. Thanks in advance

1844


What are the execution control statements?

611


What are the uses of linked server and explain it in detail?

584


What is program global area (pga) in oracle?

602






What is the maximum number of triggers that can be applied to a single table?

553


what is meant by magic query

1768


Explain rename?

549


What is a table index?

559


Can we connect to ORACLE db using Windows Authentication?

718


List out the components of logical database structure of oracle database.

581


How do you tell what your machine name is and what is its IP address?

1513


What is meant by raw datatype?

565


 What are the oracle DML commands possible through an update strategy?

579


State any two functions of oracle?

632