SELECT AGT.SETID , AGT.PROCESS_GROUP , AGT.VERSION_GRP ,ROW_NUMBER() OVER ( ORDER BY PROCESS_GROUP) AS ROW_NUMBER_5 FROM PS_ALLOC_GROUP_TBL AGT WHERE (AGT.version_grp >0 OR (AGT.version_grp = 0 AND AGT.effdt = ( SELECT MAX(AGT1.effdt) FROM PS_ALLOC_GROUP_TBL AGT1 WHERE AGT1.setid = AGT.setid AND AGT1.process_group = AGT.process_group AND agt1.version_grp = 0 AND AGT1.EFFDT <=SYSDATE))) AND AGT.version_grp = ( SELECT MAX(version_grp) FROM PS_ALLOC_GROUP_TBL AGT2 WHERE AGT2.SETID = AGT.SETID AND AGT2.PROCESS_GROUP = agt.process_group) AND AGT.BUDGET_COPY = 'N'
|