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_fe e_am,0) as odp_fee_am
, value(at.odp_in t_am,0) as odp_int_am
, value(at.tot_tr acked_uloc_bp_t rans_ct,0) as
tot_tracked_ulo c_bp_trans_ct
, value(at.tot_tr acked_uloc_bp_t rans_am,0) as
tot_tracked_ulo c_bp_trans_am
, value(at.tot_tr acked_uloc_rp_t rans_ct,0) as
tot_tracked_ulo c_rp_trans_ct
, value(at.tot_tr acked_uloc_rp_t rans_am,0) as
tot_tracked_ulo c_rp_trans_am
, value(at.tot_ul oc_trans_am,0) as tot_uloc_trans_ am
, value(at.tot_ul oc_trans_ct,0) as tot_uloc_trans_ ct
, value(at.tot_tr acked_uloc_chq_ trans_ct,0) as
tot_tracked_ulo c_chq_trans_ct
, value(at.tot_tr acked_uloc_chq_ trans_am,0) as
tot_tracked_ulo c_chq_trans_am
, value(tot_track ed_uloc_bp_tran s_ct,0)
+ value(tot_track ed_uloc_rp_tran s_ct,0)
+ value(tot_track ed_uloc_chq_tra ns_ct,0) as
total_tracked_u loc_tran_ct
, value(tot_track ed_uloc_bp_tran s_am,0) as
tot_tracked_ulo c_bp_trans_am
+ value(tot_track ed_uloc_rp_tran s_am,0)
+ value(tot_track ed_uloc_chq_tra ns_am,0) as
total_tracked_u loc_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
)
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_fe e_am,0) as odp_fee_am
, value(at.odp_in t_am,0) as odp_int_am
, value(at.tot_tr acked_uloc_bp_t rans_ct,0) as
tot_tracked_ulo c_bp_trans_ct
, value(at.tot_tr acked_uloc_bp_t rans_am,0) as
tot_tracked_ulo c_bp_trans_am
, value(at.tot_tr acked_uloc_rp_t rans_ct,0) as
tot_tracked_ulo c_rp_trans_ct
, value(at.tot_tr acked_uloc_rp_t rans_am,0) as
tot_tracked_ulo c_rp_trans_am
, value(at.tot_ul oc_trans_am,0) as tot_uloc_trans_ am
, value(at.tot_ul oc_trans_ct,0) as tot_uloc_trans_ ct
, value(at.tot_tr acked_uloc_chq_ trans_ct,0) as
tot_tracked_ulo c_chq_trans_ct
, value(at.tot_tr acked_uloc_chq_ trans_am,0) as
tot_tracked_ulo c_chq_trans_am
, value(tot_track ed_uloc_bp_tran s_ct,0)
+ value(tot_track ed_uloc_rp_tran s_ct,0)
+ value(tot_track ed_uloc_chq_tra ns_ct,0) as
total_tracked_u loc_tran_ct
, value(tot_track ed_uloc_bp_tran s_am,0) as
tot_tracked_ulo c_bp_trans_am
+ value(tot_track ed_uloc_rp_tran s_am,0)
+ value(tot_track ed_uloc_chq_tra ns_am,0) as
total_tracked_u loc_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
)