SELECT A.BUSINESS_UNIT , A.PROJECT_ID , B.ACTIVITY_ID , SUM((CASE WHEN A.AN_GRP_TOT_COSTS = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE THEN B.RESOURCE_AMOUNT ELSE 0 END)) AS ACTUAL_AMOUNT , SUM((CASE WHEN A.AN_GRP_ACTV_BUD = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE THEN B.RESOURCE_AMOUNT ELSE 0 END)) AS BUDGET_AMOUNT , SUM((CASE WHEN A.AN_GRP_ACTV_BUD = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND B.ACCOUNTING_DT <= %CurrentDateIn THEN B.RESOURCE_AMOUNT ELSE 0 END)) AS BUD_TO_DATE , SUM((CASE WHEN A.AN_GRP_TOT_COSTS = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND B.UNIT_OF_MEASURE = 'MHR' THEN B.RESOURCE_QUANTITY WHEN A.AN_GRP_TOT_COSTS = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND B.UNIT_OF_MEASURE = 'MDY' THEN B.RESOURCE_QUANTITY * A.PC_HOURS_PER_DAY ELSE 0 END )) AS ACTUAL_HOURS , SUM((CASE WHEN A.AN_GRP_ACTV_BUD = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND B.UNIT_OF_MEASURE = 'MHR' THEN B.RESOURCE_QUANTITY WHEN A.AN_GRP_ACTV_BUD = L.ANALYSIS_GROUP AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND B.UNIT_OF_MEASURE = 'MDY' THEN B.RESOURCE_QUANTITY * A.PC_HOURS_PER_DAY ELSE 0 END )) AS BUDGET_HOURS FROM PS_PROJECT A , PS_PC_SUMMARY_TBL B , PS_PROJ_AN_GRP_MAP L WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.PROJECT_ID = B.PROJECT_ID AND A.SET_OVERRIDE = L.SETID AND (A.AN_GRP_TOT_COSTS = L.ANALYSIS_GROUP OR A.AN_GRP_ACTV_BUD = L.ANALYSIS_GROUP) AND B.ANALYSIS_TYPE = L.ANALYSIS_TYPE AND A.EFF_STATUS = 'A' GROUP BY A.BUSINESS_UNIT , A.PROJECT_ID, B.ACTIVITY_ID
|