I have the following Query I was hoping you guys could give me some ideas on getting the last 2 columns I need.
The columns I need help coming up with are "Active_AR_Balance" AND "Average Days Out (ADO)"
The Active_AR_Balance is everything up though that Month.
The average days out is the AR Balance divided by payments posted in the last 90 days (or 3 months)
Any help or ideas would be great because I am a bit Stumped.
Thanks,
The columns I need help coming up with are "Active_AR_Balance" AND "Average Days Out (ADO)"
The Active_AR_Balance is everything up though that Month.
The average days out is the AR Balance divided by payments posted in the last 90 days (or 3 months)
Any help or ideas would be great because I am a bit Stumped.
Thanks,
Code:
SELECT
C.CPCODE "Group_Num"
, L.LOCNAME "Site_Name"
,trunc(to_date(C.POSTDATE,'j'),'MONTH') "Month"
,SUM(CASE WHEN (C.TYPE='C') THEN C.AMOUNT ELSE 0 END) "Gross_Charges"
,SUM(CASE WHEN (C.TYPE='P') THEN C.AMOUNT ELSE 0 END) "Gross_Payments"
,SUM(CASE WHEN (C.TYPE='A') THEN C.AMOUNT ELSE 0 END) "Gross_Adjustments"
,0 "Active_AR_Balance"
,0 "Average Days Out (ADO)"
FROM
MEDCHARGES C
LEFT JOIN MEDLOCATIONS L ON ((C.CPCODE = L.LOCCPCODE) AND (L.LOCCODE=C.DOCLOC))
WHERE
(C.CPCODE IN ('1','2','3'))
AND (C.SPLITFLAG IS NULL)
AND (C.POSTDATE IS NOT NULL)
AND (C.POSTDATE <= to_Number(to_char((trunc(sysdate,'MONTH')-1),'J')))
GROUP BY
C.CPCODE
, L.LOCNAME
,trunc(to_date(C.POSTDATE,'j'),'MONTH')