Re: Nested DECODE?
Date: 1997/02/23
Message-ID: <19970223112000.GAA02975_at_ladder02.news.aol.com>#1/1
The only way to do this is to join the tables in the query and then code
the decode as
decode(wms.w2,null,decode(asl.a2,null,'nu',asl.a2),wms.w2)
for two tables wms and asl.
Subject: Nested DECODE?
From: S Fundarek <sfware_at_idirect.com> Date: Fri, 21 Feb 1997 10:48:12 -0500
Message-ID: <330DC3BC.4ED8_at_idirect.com>
Can anyone tell me if it is possible (and if so, how) to nest DECODE clauses within a select statement?
For example, I want to select a from tbla, except if a is null, then I want b from tblb, except if b is null then I want c from tblc.
This works:
select decode(a2,'', 'nu',a2) from asl where a1 = 'K1';
but if I try to replace 'nu' with a subselect-decode, it doesn't as given:
select decode(w2,'',
(select decode(a2,'','nu', a2) from asl where a1 = 'K1' )
, w2) from wms where w1 = 'K1';
Oracle returns ORA-00936: missing expression.
Any suggestions would be helpful
-steven
sfware_at_idirect.com
Received on Sun Feb 23 1997 - 00:00:00 CET