select Nth highest salary by using rownum

Answer Posted / srinu

SELECT * FROM EMP WHERE SAL=(SELECT MIN(SAL) FROM ( SELECT
DISTINCT(SAL) FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<'&N');

ANS::

EMPNO ENAME JOB MGR HIREDATE SAL
COMM DEPTNO
------ ---------- --------- ---------- --------- ----------
---------- ----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

SELECT * FROM EMP WHERE SAL=(SELECT MIN(SAL) FROM ( SELECT
SAL FROM EMP ORDER BY SAL DESC) WHERE ROWNUM<'&N');



EMPNO ENAME JOB MGR HIREDATE SAL
COMM DEPTNO
------ ---------- --------- ---------- --------- ----------
---------- ----------
7788 SCOTT ANALYST 7566 19-APR-87 3000
20
7902 FORD ANALYST 7566 03-DEC-81 3000
20

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages of rdbms?

481


Mention the differences between unique key and primary key

469


why an information gap exists in most organizations.

529


What are the different types of database keys?

469


What do you mean by index hunting?

515






What is a database in healthcare?

486


What is the structure of a table in database?

518


What is rdms?

485


What is index hunting?

738


What is end users in dbms?

486


How do you set a primary key?

489


How to load a file into database column?

513


What is the difference between internal and external schema?

442


Describe reporting lifecycle?

502


What are the advantages of using Query Strings?

607