Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: calculated value in a DECODE statement

Re: calculated value in a DECODE statement

From: DA Morgan <damorgan_at_exxesolutions.com>
Date: Mon, 17 Mar 2003 15:24:23 -0800
Message-ID: <3E765927.F9962B17@exxesolutions.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US