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

From: Jared Still <jared_at_psnw.com>
Date: 1996/11/16
Message-ID: <Pine.BSI.3.95.961116222313.12352C-100000_at_mammoth.psnw.com>#1/1


On Wed, 13 Nov 1996, Sridhar Subramaniam wrote:

> 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' ).
> --
>

Check out the comprehensive article on this in OTJ. ( Oracle Tech Journal )

Jared Still
DBA/SysAdmin
ValueRx
jared_at_psnw.com
stillj_at_valuerx.com Received on Sat Nov 16 1996 - 00:00:00 CET

Original text of this message