title: Teradata SQL EXPAND + ACCUMULATE
body: <p>I have on-boarding data, counting IDs over time. I have expanded the data, but I also need to accumulate.</p>
  
  <p>I have:</p>
  
  <pre><code>ONBOARDING_DATE ONBOARDED ONBOARDED_EXPANDED
  12/06/2018                          
  13/06/2018                          
  14/06/2018            2            2
  15/06/2018                         2
  17/06/2018                         2
  18/06/2018            5            5
  19/06/2018                         5
  20/06/2018                         5
  </code></pre>
  
  <p>I need it to accumulate as more IDs are being onboarded, but not able to find the right function that will combine with expand.</p>
  
  <pre><code>ONBOARDING_DATE ONBOARDED ONBOARDED_EXPANDED_ACCUMULATED
  12/06/2018                        
  13/06/2018                        
  14/06/2018            2            2
  15/06/2018                         2
  17/06/2018                         2
  18/06/2018            5            7
  19/06/2018                         7
  20/06/2018                         7
  </code></pre>
  
  <p>My script,</p>
  
  <pre><code>SELECT 
  
  a.ONBOARDING_DATES
  , b.ONBOARDED
  , SUM(ONBOARDED) OVER ( PARTITION BY 1
                      ORDER BY ONBOARDING_DATE ASC
                      RESET WHEN ONBOARDED&lt;&gt;0 ) AS ONBOARDED_EXPANDED
  
  FROM
  
          (
          SELECT 
  
          CAST(CALENDAR_DATE AS DATE) AS ONBOARDING_DATES FROM 
  SYS_CALENDAR.CALENDAR
  
          WHERE ONBOARDING_DATES BETWEEN ADD_MONTHS(CURRENT_DATE, - 9)  AND ADD_MONTHS(CURRENT_DATE, + 9)
  
          ) a
  
  LEFT JOIN
      (
  
              SELECT DISTINCT
  
              COUNT(ID) AS ONBOARDED
              , WAVE_DATE
  
              FROM ENV0.R_ONBOARDING
  
              WHERE WAVE_DATE IS NOT NULL
  
              GROUP BY WAVE_DATE
  
      ) b
  
      ON a.ONBOARDING_DATS = b.WAVE_DATE
  
      ORDER BY a.ONBOARDING_DATE
  </code></pre>
  
  <p>Thank you for any assistance.</p>