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


Please Help Members By Posting Answers For Below Questions

what are the advantages of sql ? : Sql dba

737


what is single byte over head in oracle..?

2090


How do I run sql?

826


What is the difference between rename and alias?

971


how to check server status with 'mysqladmin'? : Sql dba

784






what is a view? : Sql dba

813


What is dml with example?

728


How to use distinct and count in sql query? Explain

765


What is file based approach?

663


what is a tablespace? : Sql dba

764


Is pl sql still used?

682


what is the stuff function and how does it differ from the replace function? : Sql dba

788


What are the syntax and use of the coalesce function?

772


How to run sql statements through the web interface?

730


What are sql functions? Describe in brief different types of sql functions?

717