SELECT DISTINCT A.COMMON_ID , A.SSF_BANK_ACCT_ID , B.ACCOUNT_NAME , B.SSF_ACCT_NICKNAME ,C.DESCR FROM PS_SSF_COR_BNK_NLD A ,PS_SSF_BANK_ACCT B ,PS_EXT_ORG_TBL C WHERE A.COMMON_ID = B.COMMON_ID AND A.SA_ID_TYPE = B.SA_ID_TYPE AND A.SSF_BANK_ACCT_ID = B.SSF_BANK_ACCT_ID AND B.ACCT_STATUS = 'A' AND A.EFFDT = ( SELECT MAX(A1.EFFDT) FROM PS_SSF_COR_BNK_NLD A1 WHERE A.COMMON_ID = A1.COMMON_ID AND A.SA_ID_TYPE = A1.SA_ID_TYPE AND A1.EFFDT <= %CurrentDateIn) AND A.EFFSEQ = ( SELECT MAX(A2.EFFSEQ) FROM PS_SSF_COR_BNK_NLD A2 WHERE A.COMMON_ID = A2.COMMON_ID AND A.SA_ID_TYPE = A2.SA_ID_TYPE AND A2.EFFDT = A.EFFDT) AND B.COMMON_ID = C.EXT_ORG_ID AND C.EFFDT = ( SELECT MAX(C1.EFFDT) FROM PS_EXT_ORG_TBL C1 WHERE C.EXT_ORG_ID = C1.EXT_ORG_ID AND C1.EFFDT <= %CurrentDateIn)
|