Home » SQL & PL/SQL » SQL & PL/SQL » is there any gurru of sql/plsql
is there any gurru of sql/plsql [message #20543] Mon, 03 June 2002 23:51 Go to next message
jawadg
Messages: 19
Registered: May 2002
Junior Member
how to print the max percentage of salary in
employee table
Re: is there any gurru of sql/plsql [message #20544 is a reply to message #20543] Tue, 04 June 2002 03:28 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Here's one solution:
select percentage
  from ( select max(sal)/max(sumsal)*100 percentage
           from emp
              , ( select sum(sal) sumsal
                    from emp
                ) x
          group by empno
          order by 1 DESC
       ) temp_table
 where rownum < 2
/



No doubt that there are more ways to accomplish this.

HTH,
MHE
Re: is there any gurru of sql/plsql [message #20550 is a reply to message #20543] Tue, 04 June 2002 07:19 Go to previous messageGo to next message
sridhar
Messages: 119
Registered: December 2001
Senior Member
Here is a simple one,

SELECT ROUND((max_sal/total_sal) * 100, 2) max_percent
FROM
(Select max(sal) max_sal, sum(sal) total_sal
From emp);

Thx,
SriDHAR
Re: is there any gurru of sql/plsql [message #20562 is a reply to message #20550] Tue, 04 June 2002 22:17 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
I knew I missed something!

SriDHAR, good that there are people like you simplifying things.

MHE
Previous Topic: last row in a table
Next Topic: update table with another table
Goto Forum:
  


Current Time: Tue Apr 23 17:52:03 CDT 2024