Oracle. How can I handle outer fields with IN operator and OUTER JOIN -
i wrote query this
select * (select table2.val val1, table2.val val2, table2.val val3, table2.val val4, table2.val val5, table2.val val6, case when val1 null '10' when val3 null '20' when val5 null '30' else '40' end progress table1, table2 table1.key = table2.key(+) table2.cond in ('1','2','3','4','5','6') ) progress > '20'
this query not working. there's error in
,case when val1 null '10' when val3 null '20' when val5 null '30' else '40' end progress
this part. error says val1 incongruence.
i can resolve if use this
from table2 tb2_1, table2 tb2_2, table3 tb2_3 tb2_1.key(+) = table1.key , tb2_2.key(+) = table1.key
declare same tables several times, but
i don't want because real query more complicated this.
is there way can distinguish outer tables this?
,case when table2[1].val null '10' when table2[2].val null '20' when table2[3].val null '30' else '40' end progress
or other way. please :)
use proper explicit join
syntax:
select . . . table1 left join table2 on table1.key = table2.key , table2.cond in ('1','2','3','4','5','6')
simple rule: never use commas in from
clause. always use explicit join
syntax.
Comments
Post a Comment