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: decode statement

Re: decode statement

From: FC <flavio_at_tin.it>
Date: Tue, 25 Feb 2003 11:13:52 GMT
Message-ID: <QdI6a.230255$0v.6494341@news1.tin.it>


Or, if you are using plain SQL (not PL/SQL), instead of DECODE, use CASE.

SELECT CASE WHEN business_cd='71' AND paid_cd='H' THEN 'IL' ELSE 'NOT IN LIST' END FROM <table>...

"Isa" <isapmon_at_terra.es> wrote in message news:b0I6a.700565$Ye7.4581058_at_telenews.teleline.es...
> Hi:
>
> You can't put two colums is a decode. You must do the next:
>
> decode( BUSINESS_CD, '71', decode( PAID_CD, 'H' , 'IL', 'NOT IN LIST' ),
> 'NOT IN LIST' )
>
> This do:
> if BUSINESS_CD=71 then it's looks if PAID_CD='H' then 'IL', else 'NOT
IN
> LIST'
> if BUSINESS_CD<>71 --> 'NOT IN LIST'
> I hope it's usefull to you.
> Regards,
> Isa
>
>
> "gareth hoy" <ghoy_at_yourplus.com> escribió en el mensaje
> news:e034dbf5.0302250233.1191bedd_at_posting.google.com...
> > Hi,
> >
> > i have the following decode statement:
> > select DECODE(BUSINESS_CD, PAID_CD,'71','H','IL','NOT IN LIST')
> > from FINREPDBA.T_COMMISSION_TXN;
> >
> > What i want to do is to be able to select a value of IL when
> > business_cd =71 and paid_cd=H.
> >
> > I was using the statement:
> > select DECODE(BUSINESS_CD,'71','IL','NOT IN LIST')
> > from FINREPDBA.T_COMMISSION_TXN;
> > this worked fine.
> >
> > What am i doing wrong? How can you add a second column into a decode
> > statement?
> >
> > thanks,
> > Gareth
>
>
Received on Tue Feb 25 2003 - 05:13:52 CST

Original text of this message

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