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

What is a procedure in pl sql?

550


What is the size of partition table?

553


Why trigger is used in sql?

532


How do I view output in sql developer?

578


How is data stored on a disk?

541






How can we solve sql error: ora-00904: invalid identifier?

699


How exception is different from error?

543


What is oracle and pl sql?

663


What are triggers and its types?

554


What is difference between function and trigger?

546


how can we know the number of days between two given dates using mysql? : Sql dba

546


Table A Table B 1 1 2 1 3 1. Union & union all --> A Union B , A Union all B 2. Minus , Intersect --> A minus B , B Minus A , A Intersect B 3. Joins A join B , A Left Join B A Right Join B , A full Join B 4. %Type - Uses & Benifit 5. Truncate & Delete 6. Pragma Autonomus Transaction 7. how to Perform DDL from function or procedure 8. Can we have DML inside Function 9. Rank & Dense Rank diffrence 10. Water Mark in Oracle 11. Index , Can we have index in all column of table if no then why ?

536


How to select unique records from a table?

571


Can we update views in sql?

535


How to execute a stored procedure?

563