SELECT ERN.POSITION_NBR
,SUM(ERN.BUDGET_AMT)
,SUM(ERN.DIST_PCT)
FROM PS_DEPT_BUDGET_ERN ERN
WHERE ERN.EFFDT =
(SELECT MAX(DTB.EFFDT)
FROM PS_DEPT_BUDGET DTB
WHERE DTB.SETID = ERN.SETID
AND DTB.DEPTID = ERN.DEPTID
AND DTB.FISCAL_YEAR =
ERN.FISCAL_YEAR
AND DTB.EFFDT <=
%CURRENTDATEIN)
AND EXISTS (SELECT 'X'
FROM PS_DEPT_BUDGET DTB1
WHERE DTB1.SETID = ERN.SETID
AND DTB1.DEPTID = ERN.DEPTID
AND DTB1.FISCAL_YEAR =
ERN.FISCAL_YEAR
AND DTB1.EFFDT = ERN.EFFDT
AND DTB1.EFF_STATUS = 'A') AND EXISTS (SELECT 'X'
FROM PS_DEPT_BUDGET_DT DT
WHERE DT.SETID = ERN.SETID
AND DT.DEPTID = ERN.DEPTID
AND DT. FISCAL_YEAR =
ERN.FISCAL_YEAR
AND DT.BUDGET_BEGIN_DT <=
%CURRENTDATEIN
AND DT.BUDGET_END_DT >=
%CURRENTDATEIN)
GROUP BY ERN.POSITION_NBR
|