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

Home -> Community -> Usenet -> c.d.o.server -> Re: Need Help with SQL - Repost

Re: Need Help with SQL - Repost

From: Mike Krolewski <mkrolewski_at_rii.com>
Date: Thu, 11 Jan 2001 23:48:38 GMT
Message-ID: <93lgoj$398$1@nnrp1.deja.com>

In article <t5sc80i5ljdleb_at_corp.supernews.com>,   "Anna Henson" <anna_henson_at_yahoo.com> wrote:
> Hello Oracle Users,
>
> I would like to write a query similar to the one below, but Oracle
 does not
> accept 'IF' statement. Is there anyother way to
> write a query similar to the one below.
>
> select a.score , (If b.score in (11,12,13) then InActive=1),
> (If b.score NOT in (11,12,13) then Active=1), sum(b.Balance)
>
> from OldTable a, NewTable b
> group by a.score;
>

select a.score ,

       decode( b.score,
               11, 1,
               12, 1,
               13, 1,
               0 ) InActive,
       decode( b.score,
               11, 0,
               12, 0,
               13, 0,
               1 ) Active,
       sum(b.Balance)

from OldTable a, NewTable b
group by

   a.score,
   decode( b.score,

               11, 1,
               12, 1,
               13, 1,
               0 ),
       decode( b.score,
               11, 0,
               12, 0,
               13, 0,
               1 )



> Thanks,
>
> Anna Henson
>
>

--
Michael Krolewski
Rosetta Inpharmatics
mkrolewski_at_rii.com
              Usual disclaimers


Sent via Deja.com
http://www.deja.com/
Received on Thu Jan 11 2001 - 17:48:38 CST

Original text of this message

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