Goal: Rolling/Running total for all statements at the end of each month.
Code:
select
TRUNC(ACTHX.STMT_HX_STMT_DATE, \'MM\') AS MNTH,
COUNT(ACT
It sounds like you want the running total. You can use the analytic SUM
function for that.
select mnth,
sum(stmts) over (order by mnth) stmts
from (select TRUNC(ACTHX.STMT_HX_STMT_DATE, 'MM') AS MNTH,
COUNT(ACTHX.INVOICE) as STMTS
from ACTHX
group by TRUNC(ACTHX.STMT_HX_STMT_DATE, 'MM'))
ORDER BY mnth