How to know max three salary and their sum from table

Showing Answers 1 - 15 of 15 Answers

sad

  • Nov 24th, 2006
 

select MAX(sal),sum(sal) from table_name;

  Was this answer useful?  Yes

Rukmaj Chandavar

  • Dec 29th, 2006
 

you can try this query as an alternative, this is very simple

select * from (select distinct sal from emp order by sal desc) where rownum < 4

this gives top 3 salaries. You can add sum function on outer select query to get the sum of same.

  Was this answer useful?  Yes

YOU CAN USE DENSE RANK TO RETRIEVES MAX SALARIES AND EMPLOYEES DETAILSSELECT * FROM ( SELECT A.* ,DENSE_RANK () OVER ( ORDER BY SALARY DESC ) R FROM EMPLOYEES A) WHERE R<=3YOU WILL GT MAX THREE SALARIES EMPLOYEES DETAILS IN ORACLE ( TOTAL 4 ROWS)YOU CAN EDIT THIS TO GET THREE SALARIES ALSO

  Was this answer useful?  Yes

gtomar

  • Jul 25th, 2008
 

select sum(sal) from (select distinct sal from emp order by sal desc) where rownum < 4

try this

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions