Hey everyone,
I have the following query. This seems to work, except for some weeks, there there are no Type=A or Type=P rows. I need to have both of these come back for each no matter what, even if its 0.
Any ideas would be great.
I have the following query. This seems to work, except for some weeks, there there are no Type=A or Type=P rows. I need to have both of these come back for each no matter what, even if its 0.
Any ideas would be great.
Code:
SELECT
C.CPCODE Site,
C.BILLSTATUS FC,
C.TYPE,
Sum(C.PRAMOUNT) Payment_Amount,
to_char(C.CURRYEAR) || '-' || to_char(LPAD(C.CURRMONTH,2,0)) EOM_MONTH
FROM
CHARGES C
WHERE
((C.TYPE='P') OR (C.TYPE='A') )
AND (C.POSTDATE between to_Number(to_char(next_day(trunc(sysdate)-371,'SUNDAY'),'J')) and to_Number(to_char(next_day(trunc(sysdate)-6,'SATURDAY'),'J')))
GROUP BY
C.CPCODE,
C.BILLSTATUS,
C.TYPE,
to_char(C.CURRYEAR) || '-' || to_char(LPAD(C.CURRMONTH,2,0))