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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain ttitle and btitle.

674


How to run sql commands in sql*plus?

589


What are the two characteristics of a primary key?

493


What is varchar sql?

620


What are dml commands?

529






Is like operator in sql case sensitive?

510


What is the purpose of my sql?

510


what is the difference between mysql_fetch_array and mysql_fetch_object? : Sql dba

558


How to add new employee details in an employee_details table with the following details

650


What is before trigger?

558


What are the advantages of sql?

560


What is the advantage of index in sql?

541


Which language is used in sql?

521


What are triggers and its uses?

595


How do you optimize a stored procedure in sql?

504