Re: DECODE or else, a little test...

From: Sridhar Subramaniam <avion_at_ozemail.com.au>
Date: 1996/11/13
Message-ID: <328998C0.29CD_at_ozemail.com.au>#1/1


L. Tseng wrote:
>
> DECODE() is probably the most powerful function in Oracle.
>
> For example
>
>
> IF colA = 1 AND colB = 1 THEN 'YES'
> ELSE 'NO'
>
> can be converted as
>
> DECODE(colA, 1, DECODE(colB, 1, 'YES', 'NO'), 'NO')
>
> BUT.....
>
> Can DECODE do the following?
>
> IF colA > 100 THEN 'A'
> ELSIF colA = 100 THEN 'B'
> ELSE 'C'
>
> Thanks,
>
> Leslie
>
Leslie,

try decode( sign( colA - 100 ), 1, 'A', 0, 'B', 'C' ).

-- 
Cheers

Sridhar Subramaniam
Avion Consulting Services
Sydney - Australia
Email : avion_at_ozemail.com.au

Disclaimer : All opinions are truly and just mine.
Received on Wed Nov 13 1996 - 00:00:00 CET

Original text of this message