Thursday, 19 November 2015

Query Project Unbilled Amount

SELECT TO_CHAR(TRUNC(PE.CREATION_DATE),'MON-YYYY') MONTH,
    (SELECT NAME FROM HR_ORGANIZATION_UNITS
          WHERE organization_id =ppa.carrying_out_organization_id ) Business_unit,
       PPA.SEGMENT1 PROJECT_NUMBER,
      PPA.NAME PROJECT_NAME,
      PPC.CUSTOMER_NAME CUSTOMER_NAME,
     XX_GET_AGREEMENT_NUM(ppa.project_id) AGREEMENT_NUMBER,
     (CASE WHEN ppc.customer_id in (4046,12040,5040,5044) THEN 'Internal'
      ELSE 'External'        
      END) INTERNAL_OR_EXTERNAL,
     -- NULL COST_CENTER,
      PE.DESCRIPTION,
     PE.BILL_TRANS_BILL_AMOUNT UNBILLED_AMOUNT
      -- PE.PROJECT_ID,
    -- PE.EVENT_TYPE,
    -- PE.BILLED_FLAG,
    -- PE.DESCRIPTION
FROM   PA_EVENT_TYPES pet,
      PA_EVENTS PE,
      PA_PROJECTS_ALL PPA,
      PA_PROJECT_CUSTOMERS_V ppc
WHERE PE.EVENT_TYPE =PET.EVENT_TYPE
AND PET.EVENT_TYPE_ID IN (10120,10121,10124)
AND PE.BILLED_FLAG='N'
AND PE.PROJECT_ID IN
  (SELECT pe.project_id
    FROM  PA_EVENTS PE,
          PA_PROJECTS_ALL PA
WHERE 1=1
AND pe.revenue_distributed_flag='Y'
AND pa.project_id =pe.project_id)
AND ppa.project_id =pe.project_id
AND ppc.project_id =ppa.project_id
ORDER BY MONTH DESC;

No comments:

Post a Comment