You should format your code to understand what you wrote as your code.
Following is my favolit way of formatting.
I found a syntax error in the SELECT list by looking into this
formatted code.
,tab3 as (
select k2.*
, value(at.odp_fee_am,0) as odp_fee_am
, value(at.odp_int_am,0) as odp_int_am
, value(at.tot_tracked_uloc_bp_trans_ct,0) as
tot_tracked_uloc_bp_trans_ct
, value(at.tot_tracked_uloc_bp_trans_am,0) as
tot_tracked_uloc_bp_trans_am
, value(at.tot_tracked_uloc_rp_trans_ct,0) as
tot_tracked_uloc_rp_trans_ct
, value(at.tot_tracked_uloc_rp_trans_am,0) as
tot_tracked_uloc_rp_trans_am
, value(at.tot_uloc_trans_am,0) as tot_uloc_trans_am
, value(at.tot_uloc_trans_ct,0) as tot_uloc_trans_ct
, value(at.tot_tracked_uloc_chq_trans_ct,0) as
tot_tracked_uloc_chq_trans_ct
, value(at.tot_tracked_uloc_chq_trans_am,0) as
tot_tracked_uloc_chq_trans_am
, value(tot_tracked_uloc_bp_trans_ct,0)
+ value(tot_tracked_uloc_rp_trans_ct,0)
+ value(tot_tracked_uloc_chq_trans_ct,0) as
total_tracked_uloc_tran_ct
, value(tot_tracked_uloc_bp_trans_am,0) as
tot_tracked_uloc_bp_trans_am
+ value(tot_tracked_uloc_rp_trans_am,0)
+ value(tot_tracked_uloc_chq_trans_am,0) as
total_tracked_uloc_tran_am
from tab2 k2
left join
cap_acct_trans_stage at
on k2.cust_id = at.cust_id
and k2.efectv_dt = at.efectv_dt
)