how to retrieve the top 3 salaries of the table using rownum

Answers were Sorted based on User's Feedback



how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

Answer / manoj tcs

select * from (select * from emp order by sal desc)
where rownum < 4;

Is This Answer Correct ?    0 Yes 0 No

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

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

how to retrieve the top 3 salaries of the table using rownum..

Answer / debbie

select * from (select sal from emp order by sal desc)
where rownum<=3

Is This Answer Correct ?    0 Yes 0 No

how to retrieve the top 3 salaries of the table using rownum..

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

Post New Answer

More SQL PLSQL Interview Questions

if a table is getting updated what happens if a function is called from sql query?

2 Answers   RBS,


in sql table follw columns r their vehicle_no|servicetype|date|location| 1234 |1FS |1-JAN|PUNE| 4561 |2FS |5-JAN|PUNE| 1234 |PS |7-JAN|PUNE| 1234 |PS |15-JAN|MUMB| i want o/p below vehicleno|1fs|1fsdate|1fslocation|1ps|1PSDATE|1PSLOC|2PS|2PS DATE|2PSLOCA e.g 1234|1FS|1JAN|PUNE|1PS|7JAN|PUNE|2PS|15JAN|MUMBAI PLS help me out to execute using sql query

1 Answers  


Why is a primary key important?

0 Answers  


Is a view faster than a stored procedure?

0 Answers  


Is like operator in sql case sensitive?

0 Answers  






What is the use of function in sql?

0 Answers  


What is primary key and foreign key with example?

0 Answers  


What is sql catalog?

0 Answers  


What is row_number () in sql?

0 Answers  


What is cursor status?

0 Answers  


What does subquery mean in sql?

0 Answers  


discuss about myisam index statistics collection. : Sql dba

0 Answers  


Categories