Re: NEWBIE: conditional query

From: N Prabhakar <N_Prabhakar_at_Socgen-Crosby.com>
Date: 1996/11/20
Message-ID: <56tigu$2ft_at_newton.pacific.net.sg>#1/1


"Peter Wenker" <peter.wenker_at_mci.com> writes: > I'm trying to select different values from a DATE field based upon the
> value of the date. Specifically, I want to query all rows in a table with
> a DATE field. I want the query to return a value of 'CLOSED' if the date
> is less than or equal to SYSDATE, and NULL if the date is greater than
> SYSDATE. Is this possible? I'm familiar with SQL*PLUS but not as
> familiar with its advanced functionality.
>
> Appreciate any help - thanks - john.sauer_at_MCI.com
> (please cc peter.wenker_at_MCI.com)

Hi there,

Try the following statement

select decode(sign(date_field - sysdate),0,'CLOSED',

                                         -1,'CLOSED',
                                          1,NULL)
from <table_name>

Regards

N.Prabhakar Received on Wed Nov 20 1996 - 00:00:00 CET

Original text of this message