sql- reference value selected in main query in case statement
Is there any way IN 10g to reference the t.id (as selected in the main query )
in the case statement?
select t.id,
t.code,
case t.code
when 1 (select sum(amount_1) from
(select bal_1 amount_1 from tc tc1
where tc1.type = 'P'
and tc.tid= t.id
union
select bal_2 amount_1 from tc tc2
where tc2.type = 'Y'
and tc2.tid = t.id))
else 1000
end as mm
from t;