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

What is type and rowtype in pl sql?

0 Answers  


What are the benefits of pl sql?

0 Answers  


display null value rows with out using null function?

8 Answers   Infosys,


one of the column in my table contains the data like SAL ---- 1000 1000 2000 3000 3000 So my requirement is i want output like SAL --- 1000 2000 3000 it mean i want to delete duplicate rows only how should u write query?

9 Answers   TCS,


Why does %isopen return false for an implicit cursor?

1 Answers  






What is cursor and its types?

0 Answers  


How do I create a memory optimized filegroup?

0 Answers  


What do you mean by field in sql?

0 Answers  


Why does sql need a server?

0 Answers  


can we write stored function in out parameters? how to call through select statement? how to written more than one value plz give the exmple?

1 Answers  


what is 'mysqldump'? : Sql dba

0 Answers  


What is string join?

0 Answers  


Categories