Hi John, really appreciate your input on this and sorry if i havent explained too clearly. I dont know if its possible to attach the report layout here..? Anyhow, your assumption re the date range is correct (although lack of data in our system at the moment has made it difficult for me to test my sql with + 365 date calc, which is as follows (without joins to several other tables for additional info)
The amounts in the date buckets are based on summed values (E.FOREIGN_AMOUNT for current and F.RESOURCE_AMOUNT for subsequent 11 months)
The other thing i cant figure out is if the accounting date (used for 'current' date bucket) doesnt exist for the input parameter date, i'd like to display a blank date and still retrive the next 12 months payment data... for now im just selecting the Max date <= this parameter date but if one doesnt exist i wont return any rows..an outer join doesnt want to work with the to_char translation.
SELECT
G.ACTIVITY_TYPE,
TO_CHAR(TO_DATE(E.ACCOUNTING_DT),'MMYYYY'),
TO_CHAR(TO_DATE(F.PAYMENT_DT),'MMYYYY'),
SUM(E.FOREIGN_AMOUNT),
SUM(F.RESOURCE_AMOUNT)
FROM RESOURCE E,
PAYMENT F,
ACTIVITY G
WHERE E.PROJECT_ID = 'PROJECT1' --- this is a parameter
AND E.ANALYSIS_TYPE IN ('A','B')
AND TO_CHAR(TO_DATE(E.ACCOUNTING_DT),'MMYYYY') =
(SELECT MAX(TO_CHAR(TO_DATE(P.ACCOUNTING_DT),'MMYYYY'))
FROM RESOURCE P
WHERE P.BUSINESS_UNIT = E.BUSINESS_UNIT
AND P.PROJECT_ID = E.PROJECT_ID
AND P.ACTIVITY_ID = E.ACTIVITY_ID
AND TO_CHAR(TO_DATE(P.ACCOUNTING_DT),'MMYYYY')
<= TO_CHAR(TO_DATE('05-DEC-2007'),'MMYYYY')) -- this will be 'current'
-- date parameter
AND TO_CHAR(TO_DATE(F.PAYMENT_DT),'MMYYYY') > TO_CHAR(TO_DATE(E.ACCOUNTING_DT),'MMYYYY')
AND F.PAYMENT_DT <= E.ACCOUNTING_DT + 365
AND E.BUSINESS_UNIT = F.BUSINESS_UNIT (+)
AND E.PROJECT_ID = F.PROJECT_ID (+)
AND E.ACTIVITY_ID = F.ACTIVITY_ID (+)
AND E.BUSINESS_UNIT = G.BUSINESS_UNIT (+)
AND E.PROJECT_ID = G.PROJECT_ID (+)
AND E.ACTIVITY_ID = G.ACTIVITY_ID (+)
GROUP BY G.ACTIVITY_TYPE,TO_CHAR(TO_DATE(E.ACCOUNTING_DT),'MMYYYY'),TO_CHAR(TO_DATE(F.PAYMENT_DT),'MMYYYY')
ORDER BY 1,2,3
Anyhow, I'll start to build the report with your formula ideas and let you know how it goes. Thanks again, Shae