Home » Developer & Programmer » Reports & Discoverer » Using Decode in a Calculation
icon8.gif  Using Decode in a Calculation [message #216471] Sun, 28 January 2007 13:54 Go to next message
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 #216472 is a reply to message #216471] Sun, 28 January 2007 15:22 Go to previous messageGo to next message
Messages: 136
Registered: January 2006
Location: stlouis MO USA
Senior Member

Decode(sign(leave_Val-336),1,Leave_Val - 336,0)


Re: Using Decode in a Calculation [message #217558 is a reply to message #216471] Fri, 02 February 2007 15:04 Go to previous message
Messages: 44
Registered: April 2006
Location: United States of America ...

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

Previous Topic: Convert Web Layout to Paper Layout - Oracle 10g
Next Topic: please i need help (urgent)
Goto Forum:

Current Time: Sat Oct 22 13:59:11 CDT 2016

Total time taken to generate the page: 0.04147 seconds