Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Multi Column DECODE?
Assuming 8i, you can use CASE instead of DECODE like so...
Contents of file case.sql...
/*create table pol ( policytype varchar2(5),
iscat varchar2(3),
iscancelled varchar2(3)
);
insert into pol values (
'MPCI','YES','NO' );
insert into pol values (
'CRC','NO','NO' );
insert into pol values (
'MPCI','NO','NO' );
insert into pol values (
'MPCI','NO','YES' ); */
select
policytype,iscat,iscancelled,
case
when policytype = 'MPCI' AND iscat = 'YES' AND iscancelled = 'NO'
THEN 'CAT'
when policytype = 'CRC' AND iscat = 'NO' AND iscancelled = 'NO'
THEN 'CRC'
when policytype = 'MPCI' AND iscat = 'NO' AND iscancelled = 'NO' THEN 'MPCI' when policytype = 'MPCI' AND iscat = 'NO' AND iscancelled = 'YES' THEN 'cancelled'
SVRMGR> @case
POLIC ISC ISC NEWCOLUMN
----- --- --- ---------
MPCI YES NO CAT
CRC NO NO CRC
MPCI NO NO MPCI
MPCI NO YES cancelled
4 rows selected.
SVRMGR>
Hth
-Kevin
"Brian McKenzie" <mckenzb_at_altavista.net> wrote in message
news:a22c9fca.0111061044.19ba757d_at_posting.google.com...
> I have a table containing 3 columns.
>
>
>
>
>> decode(COVERAGE_01.ISCAT,'No',
> select coverage_01.policytype
> decode(COVERAGE_01.POLICYTYPE, 'MPCI',
>
![]() |
![]() |