title: Oracle Rolling or Running totals by month
body: <p>Goal: Rolling/Running total for all statements at the end of each month.</p>
  
  <p>Code:</p>
  
  <pre><code>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
      TRUNC(ACTHX.STMT_HX_STMT_DATE, 'MM')
  </code></pre>
  
  <p>Current Output:</p>
  
  <pre><code>MNTH        STMTS
  7/1/2009    1
  10/1/2010   4
  6/1/2011    26
  9/1/2011    211
  10/1/2011   163
  11/1/2011   119
  </code></pre>
  
  <p>Desired output:</p>
  
  <pre><code>MNTH        STMTS
  7/1/2009    1
  10/1/2010   5
  6/1/2011    31
  9/1/2011    242
  10/1/2011   405
  11/1/2011   524
  </code></pre>