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 are the advantages of sql ? : Sql dba
what is single byte over head in oracle..?
How do I run sql?
What is the difference between rename and alias?
how to check server status with 'mysqladmin'? : Sql dba
what is a view? : Sql dba
What is dml with example?
How to use distinct and count in sql query? Explain
What is file based approach?
what is a tablespace? : Sql dba
Is pl sql still used?
what is the stuff function and how does it differ from the replace function? : Sql dba
What are the syntax and use of the coalesce function?
How to run sql statements through the web interface?
What are sql functions? Describe in brief different types of sql functions?