how to retrieve the top 3 salaries of the table using rownum
Answer Posted / rajnish chauhan
you can put any number on Rnk.
---Top 3 salary
SELECT ROWNUM,ename,sal
FROM (
SELECT ename,sal,rank() over(ORDER BY sal DESC)rnk
FROM emp)a WHERE rnk<4
-----Top 3 Salary only
SELECT ROWNUM,ename,sal
FROM (
SELECT ename,sal,rank() over(ORDER BY sal DESC)rnk
FROM emp)a WHERE rnk=3
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is use of term?
How do you drop a trigger?
Why is there a need for sqlcode and sqlerrm variables?
What is a memo field?
what is data control language? : Sql dba
what is the difference between rownum pseudo column and row_number() function? : Sql dba
what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba
what is the difference between nested subquery and correlated subquery?
What is the difference between inner join and left join?
What does an inner join do?
Is it possible to link two groups inside a cross products after the cross products group has been created?
What is a variable in sql?
What is execution plan in sql?
How can the performance of a trigger be improved?
Do we need commit after truncate?