SELECT DISTINCT ORG.EXTERNAL_SYSTEM_ID , EXT.EXT_ORG_ID , EXT.DESCR50 FROM PS_EXT_ORG_TBL EXT , PS_SCC_ORG_EXT_KEY ORG WHERE EXT.EXT_ORG_ID = ORG.EXT_ORG_ID AND EXT.EFFDT = ( SELECT MAX(EXT_ED.EFFDT) FROM PS_EXT_ORG_TBL EXT_ED WHERE EXT.EXT_ORG_ID = EXT_ED.EXT_ORG_ID AND EXT_ED.EFFDT <= %CurrentDateIn) AND EXT.EFF_STATUS = 'A' AND ORG.EXTERNAL_SYSTEM = ( SELECT SCC_EXTERNAL_SYS FROM PS_SAD_BPVINST_NLD) AND ORG.EFFDT = ( SELECT MAX(ORG_ED.EFFDT) FROM PS_SCC_ORG_EXT_KEY ORG_ED WHERE ORG.EXT_ORG_ID = ORG_ED.EXT_ORG_ID AND ORG.EXTERNAL_SYSTEM = ORG_ED.EXTERNAL_SYSTEM AND ORG_ED.EFFDT <= %CurrentDateIn)
|