SELECT PERS.BO_ID ,BACT.RBTACCTID ,BACT.RBTACCTNAME ,BACT.RBTACCTNO FROM PS_RBT_ACCOUNT BACT , PS_BO_REL REL , PS_RD_PERSON PERS ,PS_BO_NAME BON ,PS_BO_NAME NM WHERE REL.BO_ID_2 = BACT.BO_ID AND REL.BO_ID_1 = PERS.BO_ID AND PERS.BO_ID = BON.BO_ID AND BON.PRIMARY_IND = 'Y' AND BACT.RBTCUST_BO_ID = NM.BO_ID AND NM.PRIMARY_IND = 'Y' AND REL.REL_TYPE_ID IN ( 535,536) AND REL.START_DT <= %CurrentDateIn AND REL.END_DT > %CurrentDateIn AND BACT.RBTCUST_BO_ID = BACT.RBTCONT_BO_ID AND BACT.RBTACCTSTATUS = 'ACT'
|