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