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

Plz send me Oracle Pl/Sql [1z0-147] dumps to this mail? sivakumarr1987@gmail.com

1488


What is alternate key?

520


Give us a non-computer example of preemptive and non-preemptive scheduling?

487


What is unique key in dbms?

479


What are the benefits of modeling?

485






Why do we need database management?

489


Which is the most used database?

489


What is a distributed database system?

519


What are the steps in creating a database?

478


What is ddl in dbms?

534


What is correlated subquery in dbms?

562


What are the steps to follow when preparing to create a table?

461


What is the structure of a table in database?

528


Explain the advantages of rdbms?

520


What are the different types of keys in database?

436