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 is index and also explain types of indexing in dbms?
How does index hunting help in improving query performance?
What do you mean by DBMS?
Have you written applications to retrieve stored images in a table?
What are indexes? Mention the differences between the clustered and non-clustered index?
What are the database skills?
What is entity and its types?
Is google a database?
What are the ways to tune reporting services?
write a query to retrieve the last day of next month in oracle.
What are data modelling tools?
Why is foreign key used?
When should you consider denormalization?
Write a query to create a duplicate table with and without data present?
Explain vdl (view definition language)?