SELECT A.BUSINESS_UNIT , A.PROJECT_ID , A.ACTIVITY_ID , B.PC_TRANS_ID , SUM(A.RESOURCE_AMOUNT) FROM PS_P6_WBS_ACTCF_VW A , PS_PC_TRANS_ID_DTL B WHERE B.SETID = ( SELECT I.SETID FROM PS_SET_CNTRL_REC I WHERE I.SETCNTRLVALUE = A.BUSINESS_UNIT AND I.REC_GROUP_ID = 'PC_16' AND I.RECNAME = 'PC_TRANS_ID_DTL') AND B.DETAIL_NO = ( SELECT MIN(J.DETAIL_NO) FROM PS_PC_TRANS_ID_DTL J WHERE J.SETID = B.SETID AND J.PC_TRANS_ID = B.PC_TRANS_ID AND (((J.RESOURCE_TYPE <> '%' AND J.RESOURCE_TYPE = A.RESOURCE_TYPE) AND (J.RESOURCE_CATEGORY <> '%' AND J.RESOURCE_CATEGORY = A.RESOURCE_CATEGORY) AND (J.RESOURCE_SUB_CAT <> '%'AND J.RESOURCE_SUB_CAT = A.RESOURCE_SUB_CAT)) OR ((J.RESOURCE_TYPE <> '%' AND J.RESOURCE_TYPE = A.RESOURCE_TYPE) AND (J.RESOURCE_CATEGORY <> '%' AND J.RESOURCE_CATEGORY = A.RESOURCE_CATEGORY) AND J.RESOURCE_SUB_CAT = '%') OR ((J.RESOURCE_TYPE <> '%' AND J.RESOURCE_TYPE = A.RESOURCE_TYPE) AND J.RESOURCE_CATEGORY = '%' AND (J.RESOURCE_SUB_CAT <> '%'AND J.RESOURCE_SUB_CAT = A.RESOURCE_SUB_CAT)) OR ((J.RESOURCE_TYPE <> '%' AND J.RESOURCE_TYPE = A.RESOURCE_TYPE) AND J.RESOURCE_CATEGORY = '%' AND J.RESOURCE_SUB_CAT = '%') OR (J.RESOURCE_TYPE = '%' AND (J.RESOURCE_CATEGORY <> '%' AND J.RESOURCE_CATEGORY = A.RESOURCE_CATEGORY) AND (J.RESOURCE_SUB_CAT <> '%'AND J.RESOURCE_SUB_CAT = A.RESOURCE_SUB_CAT)) OR (J.RESOURCE_TYPE = '%' AND (J.RESOURCE_CATEGORY <> '%' AND J.RESOURCE_CATEGORY = A.RESOURCE_CATEGORY) AND J.RESOURCE_SUB_CAT = '%') OR (J.RESOURCE_TYPE = '%' AND J.RESOURCE_CATEGORY = '%' AND (J.RESOURCE_SUB_CAT <> '%'AND J.RESOURCE_SUB_CAT = A.RESOURCE_SUB_CAT)) OR (J.RESOURCE_TYPE = '%' AND J.RESOURCE_CATEGORY = '%' AND J.RESOURCE_SUB_CAT = '%'))) GROUP BY A.BUSINESS_UNIT, A.PROJECT_ID, A.ACTIVITY_ID, B.PC_TRANS_ID
|