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 5 major parts of a database system?
What information can be stored in a database?
How do databases help businesses?
Define truncate and delete commands?
What is delimiter in dbms?
What is dbms and its advantages?
Enlist the cursor types.
What is concurrency control?
What is snow flake schema design in database? What's the difference between star and snow flake schema?
What is denormalization and why would someone consider doing so?
What is normalization and what are the different types of normalization?
What are the components of rdbms?
Is there an example how to configure udfaccess setting in firebird.conf?
Define union all operator and union.
How to prevent concurrent access to my data?