Print 3 highest salary

Answer Posted / saraswathi muthuraman

The previous post is to find the 3rd highest value.

Please find the below qry to find the top 3 highest salary

SQL> select a.EMP_NO,a.SAL,a.DEP_NO from emp_test a, (select
SAL,rank() over(order by sal desc) as rank_val from emp_test
group by sal)b where
2 a.sal=b.sal and b.rank_val <=3;

1003 20010 11
1001 10000 11
1001 10000 11
1002 100 11

4 rows selected.

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a text delimiter?

514


How to validate email addresses in mysql?

602


Is mysql better than oracle?

479


How many primary keys can be there in a table?

536


Is mysql a server or database?

477






Consider you have the following three tables which have to be linked together.

501


How is oracle different from mysql?

500


What is the query to display top 20 rows?

611


Why mysql is so popular?

516


What does mysql flush hosts do?

473


How to get the current date in mysql?

572


What is a delimiter in mysql?

484


What is mysql protocol?

465


Why we use mysqli instead of mysql?

565


Is mysql a free database?

488