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

Which are the different types of indexes in sql?

0 Answers  


Types of indexes. What is the default key created when a primary key is created in a table ?

5 Answers   TCS,


Difference between SUBSTR and INSTR?

3 Answers  


Which type of cursor is used to execute the dml statement?

0 Answers  


Why is nosql good?

0 Answers  






What does over partition by mean in sql?

0 Answers  


How do you know if a relationship is 2nf?

0 Answers  


How do you change a value in sql?

0 Answers  


Why is the cursor important?

0 Answers  


types of exceptions and what is meant by pragma autonomous_transaction ?what is the use.

4 Answers   3i Infotech,


What is pl sql commands?

0 Answers  


What is multiple columns?

0 Answers  


Categories