Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Decode greater than syntax
Using GREATEST is one way, here's another:
What you're basically saying is:
IF RECEIVED_DT - Sysdate > REQ_DT THEN
TRUE
ELSE
FALSE
END IF;
RECEIVED_DT - Sysdate > REQ_DT RECEIVED_DT - Sysdate - REQ_DT > REQ_DT - REQ_DT RECEIVED_DT - Sysdate - REQ_DT > 0SIGN(RECEIVED_DT - Sysdate - REQ_DT) > 0 SIGN(RECEIVED_DT - Sysdate - REQ_DT) = 1 (1=pos, 0=zero, -1=neg)
Therefore, the answer is:
DECODE(SIGN(RECEIVED_DT - Sysdate - REQ_DT),1,'TRUE',2,'FALSE')
Michael J. Ort
In article <8clite$hlp$1_at_nnrp1.deja.com>,
rainbow24k_at_my-deja.com wrote:
> IS this it???
>
> select decode( GREATEST(A,B), A, 'A is greater than B', 'B is
> greater than A')...
>
> I'm trying to make it easy on you experts! :)
>
> Any way I almost have it working, except now I'm struggling with
> inconsistent data types.
>
> Later!
>
> Suzan ....I'll probably have to post my own answer again. And this is
> my first time ever asking a question in here. :D
>
> In article <8clcsd$avc$1_at_nnrp1.deja.com>,
> rainbow24k_at_my-deja.com wrote:
> > Could someone please help me figure out how to accomplish the
following:
> >
> > DECODE((RECEIVED_DT - Sysdate) > REQ_DT, TRUE, FALSE) AS CAPTURE
> >
> > Basically, I'm wanting to set CAPTURE to True or False depending on
> > whether RECEIVED_DT is greather than REQ_DT. Hope this makes sense.
> >
> > Thanks in advance.
> >
> > Suzan
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Apr 07 2000 - 00:00:00 CDT
![]() |
![]() |