Home » SQL & PL/SQL » SQL & PL/SQL » % from Value (Oracle 9.2)
% from Value [message #350596] Thu, 25 September 2008 09:42 Go to next message
Deon Smit
Messages: 36
Registered: September 2008
Member
Hi

I have got a Value

25

and a MAX bin level.

50

I want to use for Example

Select Qty, Maxbinlevel, QTY % Maxbinlevel from SKU.

I currently have
Select Qty, Maxbinlevel from SKU.
and I get
QTY MAXBINLEVEL
25 50

Does the % function exist in Oracle?

Regards
Re: % from Value [message #350597 is a reply to message #350596] Thu, 25 September 2008 09:53 Go to previous messageGo to next message
Alessandro Rossi
Messages: 166
Registered: September 2008
Location: Rome
Senior Member
If it does the same as on C and Java, it should be the mod function.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions088.htm#i77996

Bye Alessandro
Re: % from Value [message #350598 is a reply to message #350596] Thu, 25 September 2008 09:58 Go to previous messageGo to next message
Deon Smit
Messages: 36
Registered: September 2008
Member
Not Exactly. MOD shows everthing left over. I want %.

Thanks
Re: % from Value [message #350599 is a reply to message #350598] Thu, 25 September 2008 10:02 Go to previous messageGo to next message
annagel
Messages: 220
Registered: April 2006
Senior Member
Then you are going to have to explain what you want in actual words.
Re: % from Value [message #350606 is a reply to message #350596] Thu, 25 September 2008 10:33 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Do you know what is %?

Regards
Michel
Re: % from Value [message #350609 is a reply to message #350598] Thu, 25 September 2008 10:37 Go to previous messageGo to next message
Alessandro Rossi
Messages: 166
Registered: September 2008
Location: Rome
Senior Member
I don't have a crystal ball and don't pretend I should get one.

Then why don't you use integers as operands to avoid decimals.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions135.htm#i78633
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions200.htm#i79729



Bye Alessandro

[Updated on: Thu, 25 September 2008 10:38]

Report message to a moderator

Re: % from Value [message #350725 is a reply to message #350609] Fri, 26 September 2008 00:59 Go to previous messageGo to next message
NoraizOraDev
Messages: 11
Registered: September 2008
Junior Member
You must explain your question. what you want to do with '%'?
May be there is an alternate solution possible for you.
Re: % from Value [message #350737 is a reply to message #350596] Fri, 26 September 2008 01:38 Go to previous messageGo to next message
rajy_salim
Messages: 204
Registered: January 2008
Location: Beirut - Lebanon
Senior Member
If you meant that you want to retrieve the 'percentage', then use: (QTY / Maxbinlevel) * 100
(25 / 50) * 100 = 50%.

Select Qty, Maxbinlevel, QTY / Maxbinlevel * 100
from SKU.

Rajy
Re: % from Value [message #350793 is a reply to message #350737] Fri, 26 September 2008 06:39 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
rajy_salim wrote on Fri, 26 September 2008 07:38
If you meant that you want to retrieve the 'percentage', then use: (QTY / Maxbinlevel) * 100
(25 / 50) * 100 = 50%.

Select Qty, Maxbinlevel, QTY / Maxbinlevel * 100
from SKU.

Rajy

Wrong! (25/50)*100 = 50 NOT 50%
Re: % from Value [message #350798 is a reply to message #350596] Fri, 26 September 2008 06:52 Go to previous messageGo to next message
rajy_salim
Messages: 204
Registered: January 2008
Location: Beirut - Lebanon
Senior Member
haha!
icon4.gif  Re: % from Value [message #353215 is a reply to message #350793] Sun, 12 October 2008 23:07 Go to previous message
NoraizOraDev
Messages: 11
Registered: September 2008
Junior Member
If you want to get result in 'number' then 50 is right one. by adding '%' with result like '50%' will be a char/varchar type.
To get result like '50%'

Select Qty, Maxbinlevel, QTY / Maxbinlevel * 100||'%'from SKU.

It will turn into char type and can't use for furthur calculations.
Previous Topic: Ceate a type with a method inside
Next Topic: Using analytical functions
Goto Forum:
  


Current Time: Sat Dec 03 09:58:08 CST 2016

Total time taken to generate the page: 0.09546 seconds