title: Postgresql Time Series for each Record
body: <p>I'm having issues trying to wrap my head around how to extract some time series stats from my Postgres DB.</p>
  
  <p>For example, I have several stores. I record how many sales each store made each day in a table that looks like:</p>
  
  <pre><code>+------------+----------+-------+
  |    Date    | Store ID | Count |
  +------------+----------+-------+
  | 2017-02-01 |        1 |    10 |
  | 2017-02-01 |        2 |    20 |
  | 2017-02-03 |        1 |    11 |
  | 2017-02-03 |        2 |    21 |
  | 2017-02-04 |        3 |    30 |
  +------------+----------+-------+
  </code></pre>
  
  <p>I'm trying to display this data on a bar/line graph with different lines per Store and the blank dates filled in with 0.</p>
  
  <p>I have been successful getting it to show the sum per day (combining all the stores into one sum) using <code>generate_series</code>, but I can't figure out how to separate it out so each store has a value for each day... the result being something like:</p>
  
  <pre><code>["Store ID 1", 10, 0, 11,  0]
  ["Store ID 2", 20, 0, 21,  0]
  ["Store ID 3",  0, 0,  0, 30]
  </code></pre>