Re: DECODE? IIF?

From: Mike J Cox <mike_at_kane.demon.co.uk>
Date: 1995/08/06
Message-ID: <102440322wnr_at_kane.demon.co.uk>#1/1


>
> I'm trying to pull data from 2 different fields, depending on
> the result of a comparison.
>
> It seems that decode won't let me do a "field < x".
> Is there an immediate IF statement in SQLPlus, like
> in Access, dBase, etc, etc, etc?
>
Cathy,

you can do either nvl(actual,planned)

If actual if null then use the planned

or decode(sign(date-sysdate),-1,actual,0,actual,planned)

if the date is less than today or today then we are in the past so use actual otherwise use planned.

decode(sign(x-y)) allows you to do ifs > or < or = all in the same sql statement, mucho useful.

Mike


Michael Cox          Input Technolgies Ltd
Email                mike_at_kane.demon.co.uk
Compuserve           100045.1715_at_compuserve.com
******************************************************************************
Received on Sun Aug 06 1995 - 00:00:00 CEST

Original text of this message