Using Decode in a Calculation [message #216471] |
Sun, 28 January 2007 13:54 |
dabozarth
Messages: 4 Registered: January 2007
|
Junior Member |
|
|
Can anyone help me? I am trying to use decode to do a calculation when a value is greater than 336. However it does not seem to be working. Does anyone have any suggestions?
Decode(leave Val, > 336, Leave Val - 336)
Please help I am completely stuck.
|
|
|
|
Re: Using Decode in a Calculation [message #217558 is a reply to message #216471] |
Fri, 02 February 2007 15:04 |
Ericle
Messages: 44 Registered: April 2006 Location: United States of America ...
|
Member |
|
|
Srini's solution is correct. However, if the value is less than 336 and you want to leave it as is (instead of making it 0), then you would have
Decode(sign(leave_val - 336),1,leave_val - 336,leave_val)
Or, you could just use CASE.
CASE WHEN leave_val > 336 THEN leave_val - 336 ELSE leave_val END
[Updated on: Fri, 02 February 2007 15:20] Report message to a moderator
|
|
|