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 use of trigger?

0 Answers  


which will fire first ? Trigger or Constraint

24 Answers   i2, IBM,


Why commit is not used in triggers?

0 Answers  


If we have n no of columns in a table, can we add new column in that table with not null constraint?

2 Answers  


What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?

4 Answers  






How to return more than one value from a function?

11 Answers   Satyam,


Which one is the Best approach to put code, among Triggers and Procedures? Explain?

1 Answers   Sierra Atlantica,


What are different clauses used in sql?

0 Answers  


what command is used to create a table by copying the structure of another table including constraints ?

6 Answers   CMC, eicc,


How can analyze query after generating explain plan ?

2 Answers   Thermotech,


What is the source code of a program?

0 Answers  


In table a 1lakh data is present,in table b 20 thousand data is present, to get unique data from table a and b which join to be considered. whether right outer join or left inner join. 

2 Answers   GE,


Categories