how to retrieve the top 2 salaried persons from a database?

Answers were Sorted based on User's Feedback



how to retrieve the top 2 salaried persons from a database?..

Answer / abc

Select salary from (select salary from employees order by
salary desc) where rownum <=2;

Is This Answer Correct ?    8 Yes 1 No

how to retrieve the top 2 salaried persons from a database?..

Answer / rajkumar

select top 1 colmn from table_name where colmn in
(select top 2 colmn from table_name where colmn is not
null order by colmn desc)

Is This Answer Correct ?    2 Yes 0 No

how to retrieve the top 2 salaried persons from a database?..

Answer / arun

select salary from(select salary from(select distinct salary from employees order by salary desc) where rownum<=2 order by salary) where rownum=1;

Is This Answer Correct ?    1 Yes 0 No

how to retrieve the top 2 salaried persons from a database?..

Answer / srinivas

select * from emp m
where
(select count(distinct sal)+1 from emp s
where s.sal>m.sal)<=2
order by sal desc

Is This Answer Correct ?    1 Yes 0 No

how to retrieve the top 2 salaried persons from a database?..

Answer / mamta

Select sal
from salary_tbl
where rownum <= 2
order by sal desc;

Is This Answer Correct ?    0 Yes 0 No

how to retrieve the top 2 salaried persons from a database?..

Answer / anusreekr

An error is occuring saying "unknown column rownum".
Please let me know where rownum feature is available in all
the mysql versions.The server version i am using is 5.5.21.

Thanks

Is This Answer Correct ?    0 Yes 3 No

how to retrieve the top 2 salaried persons from a database?..

Answer / unknown

Select salary from (select salary from employees) where
rownum <=2;

Is This Answer Correct ?    1 Yes 7 No

Post New Answer

More SQL PLSQL Interview Questions

explain the difference between bool, tinyint and bit. : Sql dba

0 Answers  


What is TABLE SPACE?

4 Answers   ABB, TCS,


what is isam? : Sql dba

0 Answers  


Why use subqueries instead of joins?

0 Answers  


What is an exception in PL/SQL? What are the two types of exceptions?

0 Answers  






Why is pl sql used?

0 Answers  


What is trigger in sql? Explain

0 Answers  


Explain the difference between rename and alias?

0 Answers  


Explain locks? : Transact sql

0 Answers  


Can you sum a count in sql?

0 Answers  


How to revise and re-run the last sql command?

0 Answers  


How to copy a table in another table with datas?

9 Answers  


Categories