title: Postgresql - Cumulative sum of created users
body: <p>I have a <code>users</code> table with a timestamp when each user was created. I'd like to get the cumulative sum of users created per month.</p>
  
  <p>I do have the following query which is working, but it's showing me the sum on a per day basis. I have a hard time going from this to a per month basis.</p>
  
  <pre><code>SELECT 
      created_at,
      sum(count(*)) OVER (ORDER BY created_at) as total
  FROM users
  GROUP BY created_at 
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>created_at  count
  -----------------
  2016-07  100
  2016-08  150
  2016-09  200
  2016-10  500
  </code></pre>
  
  <p>Former reading:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/22841206/calculating-cumulative-sum-in-postgresql">Calculating Cumulative Sum in PostgreSQL</a></li>
  <li><a href="https://stackoverflow.com/questions/5698452/count-cumulative-total-in-postgresql/5700744#5700744">Count cumulative total in Postgresql</a></li>
  <li><a href="https://dba.stackexchange.com/questions/107485/rolling-sum-count-average-over-date-interval">Rolling sum / count / average over date interval</a></li>
  <li><a href="https://stackoverflow.com/questions/32490946/cumulative-sum-of-values-by-month-filling-in-for-missing-months">Cumulative sum of values by month, filling in for missing months</a></li>
  <li><a href="https://stackoverflow.com/questions/8844903/postgres-window-function-and-group-by-exception/8845062#8845062">Postgres window function and group by exception</a></li>
  </ul>