how to retrieve the top 3 salaries of the table using rownum
Answers were Sorted based on User's Feedback
Answer / seema
select sal from (select distinct sal from emp order by sal
desc ) where rownum < 3;
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kavitha
select employee_id,last_name,salary
from employees
where rownum <=3
order by salary desc
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / kamal
Hello Sir
I wana to see this that how to retrieve 3 top salary by
subqurey can you gave me this answer.
Thanks
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / saisravanthi
select salary from
(select salary,rownum from salary_tab
order by salary_tab desc)
where rownum < 4;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manoj tcs
select * from (select * from emp order by sal desc)
where rownum < 4;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / raveendran
SELECT EMP_BASICS,ROWNUM FROM EMPLOYEE_MASTER WHERE
EMP_BASICS IS NOT NULL AND ROWNUM<=3 ORDER BY EMP_BASICS
DESC
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / k.thrilok kumar
select rownum, sal from (select * from emp order by sal
desc) where rownum<=3
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
Answer / debbie
select * from (select sal from emp order by sal desc)
where rownum<=3
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chiru
select sal from (select distinct sal from emp order
by sal desc)
where rownum<4 ;
| Is This Answer Correct ? | 0 Yes | 0 No |
what is log shipping? : Sql dba
What are the advantages of pl sql?
overloading of stored procedure is possible in oracle?
When can we use the where clause and the having clause?
what is constraining table?
four procedures is are there should i write their in a package
Explain alias in sql?
How to fetch the rows by dynamicaly passing table name through cursor?
Difference between truncate, delete and drop commands?
explain what is mysql? : Sql dba
What are the difference between Functions/Stored Procs and Triggers and where are they used.
what are aggregate and scalar functions? : Sql dba
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)