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
What are the advantages of rdbms?
Mention the differences between unique key and primary key
why an information gap exists in most organizations.
What are the different types of database keys?
What do you mean by index hunting?
What is a database in healthcare?
What is the structure of a table in database?
What is rdms?
What is index hunting?
What is end users in dbms?
How do you set a primary key?
How to load a file into database column?
What is the difference between internal and external schema?
Describe reporting lifecycle?
What are the advantages of using Query Strings?