title: How to do cumulative sum in PostgreSQL on a resulting column?
body: <p>I have this PostgreSQL query that grabs total number of signed up users:</p>
  
  <pre><code>SELECT concat(extract(MONTH from created_at),'-', extract(year from created_at)) AS "Month", 
  count(case when is_accountant='t' then email end) AS "Total AB Signups",
  count(case when is_accountant='f' then email end) AS "Total SMB Signups",
  COALESCE(count(case when is_accountant='t' then email end))
  +COALESCE(count(case when is_accountant='f' then email end)) as "Total Signups"
  from users
  group by 1,extract(month from created_at),extract(year from created_at)
  HAVING count(case when is_accountant='t' then email end)&lt;&gt;0 
  AND count(case when is_accountant='f' then email end)&lt;&gt;0
  order by extract(year from created_at),extract(month from created_at); 
  </code></pre>
  
  <p>Which results in something like this:</p>
  
  <pre><code>Month   | Total AB Signups | Total SMB Signups | Total Signups
  -------------------------------------------------------------
  08-2015 | 2                | 5                 | 7
  09-2015 | 4                | 8                 | 12
  </code></pre>
  
  <p>How would I add a column for the cumulative sum, like below?</p>
  
  <pre><code>Month   | Total AB Signups | Cumulative AB | Total SMB Signups | Cumulative SMB | Total Signups | Cumulative Total
  -----------------------------------------------------------------------------------------------------------------
  08-2015 | 2                | 2             |5                  | 5              | 7             | 7
  09-2015 | 4                | 6             |8                  | 13             | 12            | 19
  </code></pre>