sel a.DEBT_MGR_RTR_ACCT_NUM, a.PLCMT_STRT_DT , a.PLCMT_END_DT , AGT_AGY_CD , CATG_CD
from prdm.rcvry_acct_agy_plcmt a
left join prdm.rcvry_agy_work_que_vw c
on a.agy_work_que_id = c.agy_work_que_id
left join prdm.RCVRY_ACCT_ACTVY_NOTE b
on a.debt_mgr_rtr_acct_num = b.debt_mgr_rtr_acct_num
and actvy_dt between a.plcmt_strt_dt and coalesce(a.plcmt_end_dt, date)
and a.DEBT_MGR_RTR_ACCT_NUM = b.DEBT_MGR_RTR_ACCT_NUM
left join (select DEBT_MGR_RTR_ACCT_NUM, max (trxn_dt) as Lst_PMT
from prdm.RCVRY_ACCT_PMT_TRXN
GROUP BY debt_mgr_rtr_acct_num)x
on a.debt_mgr_rtr_acct_num = x.debt_mgr_rtr_acct_num
where agt_agy_cd in
('AGENT1','AGENT2','AGENT3')
and a.plcmt_end_dt is null
and a.plcmt_strt_dt = date - 22
and CATG_CD not IN ('AC', 'AB', 'AT', 'LK', 'SI', 'JK');this is the query you expected?
↧