Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: calculated value in a DECODE statement
Marc Miller wrote:
> Hi all,
>
> I'm a fairweather Oracle sql front ender and I need some help on a DECODE.
>
> I have a numeric field that, if it is greater than 0, return the field, else
> return 0.
>
> I've tried ;
> DECODE(numfield, > 0, numfield,0)
> DECODE(numfield, numfield > 0, numfield,0)
> DECODE(numfield, (numfield) > 0, numfield,0)
>
> and several iterations and I now have no hair on my head.
>
> Can anyone shed some light on this?
>
> TIA,
> Marc Miller
> Commonwealth Telephone Company
You can use CASE ... but why make this more difficult than need be?
Why not:
IF numfield > 0 THEN
...
ELSE
...
END IF;
Daniel Morgan
Received on Mon Mar 17 2003 - 17:24:23 CST
![]() |
![]() |