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
Define a temp table?
what are the types of join and explain each? : Sql dba
Mention what are different methods to trace the pl/sql code?
What are keys in sql?
When is the explicit cursor used ?
What is rename command in sql?
How do you optimize a stored procedure in sql?
What is sql comments?
what are all the different types of indexes? : Sql dba
Explain how you can copy a file to file content and file to pl/sql table in advance pl/sql?
Explain what is sql?
what is the difference between mysql_fetch_array and mysql_fetch_object? : Sql dba
what is a field in a database ? : Sql dba
Why procedure is used in sql?
What is sqlcommand?