Home » SQL & PL/SQL » SQL & PL/SQL » calculate percent(toad oracle8.5) (toad for oracle 8.5)
calculate percent(toad oracle8.5) [message #281365] Fri, 16 November 2007 09:51 Go to next message
labyrinth248
Messages: 14
Registered: November 2007
Junior Member
Hello,
I wanted to get a percent of these two columns for a third column:
sum(decode(dol.leak_origin_type, 'Customer Reported', '1', '0')),
sum(decode(dol.priority, 'Prospect Emergency', '1', '0')),


can anyone help
Thanks
Re: calculate percent(toad oracle8.5) [message #281368 is a reply to message #281365] Fri, 16 November 2007 10:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Percent is 100*value/total

Regards
Michel
Re: calculate percent(toad oracle8.5) [message #281388 is a reply to message #281365] Fri, 16 November 2007 11:27 Go to previous messageGo to next message
labyrinth248
Messages: 14
Registered: November 2007
Junior Member
Its working except for when its supposed to be 100% it just says "1". How can I fix that?

Thanks
Re: calculate percent(toad oracle8.5) [message #281396 is a reply to message #281388] Fri, 16 November 2007 12:11 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
No it doesn't, it says 100.

Regards
Michel
Re: calculate percent(toad oracle8.5) [message #281400 is a reply to message #281365] Fri, 16 November 2007 12:50 Go to previous messageGo to next message
labyrinth248
Messages: 14
Registered: November 2007
Junior Member
oh ok
Re: calculate percent(toad oracle8.5) [message #281480 is a reply to message #281400] Sat, 17 November 2007 03:35 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
There's the TO_CHAR function available, which would enable you to properly format calculated value. For example:
SQL> select comm, sal, comm/sal*100, TO_CHAR(comm/sal*100, '990.00') formatted
  2  from emp where ename = 'FORD';

      COMM        SAL COMM/SAL*100 FORMATT
---------- ---------- ------------ -------
       300       3000           10   10.00
Previous Topic: LONG to CLOB in Java Stored Function
Next Topic: drop all tables
Goto Forum:
  


Current Time: Fri Dec 09 17:21:03 CST 2016

Total time taken to generate the page: 1.30414 seconds