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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Using IF statements in Select statements

Re: Using IF statements in Select statements

From: Arman Rawls <no_spam_arawls_at_qwest.net>
Date: Wed, 1 Nov 2000 20:26:00 -0700
Message-ID: <Gb5M5.1626$q81.492112@news.uswest.net>

If using Oracle 8i then use the CASE function.

<casey_allred_at_my-deja.com> wrote in message news:8tqca2$tqq$1_at_nnrp1.deja.com...
> I have the following SQL from SQLServer that I need to convert to PLSQL
> v 8:
>
> SELECT FD17 = CASE WHEN 17 - Sunset > 1 THEN 1 WHEN 17 - Sunset <
> 0 THEN 0 ELSE 17 - Sunset END
> FROM TABLE_FOO
>
> Sunset is a float
>
> I was thinking that this:
>
> SELECT DECODE(SIGN((17-Sunset)-1), 1, 1, -1, 0, 0, 17 - Sunset) as FD17
> FROM TABLE_FOO
>
> would do it but it does not account for the case when (17 - Sunset)<=1
> and > 0. Any ideas?
> -Casey
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Wed Nov 01 2000 - 21:26:00 CST

Original text of this message

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