| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Need Help with SQL - Repost
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)
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
![]() |
![]() |