title: Postgres simple 'pivot' table
body: <p>If I have a table of data as such</p>
  
  <pre><code>name   |   type   |  count
  
  test   | blue     |  6
  test2  | red      |  3
  test   | red      |  4
  </code></pre>
  
  <p>How can I query it such that I get a table:</p>
  
  <pre><code>name  |  num_red  | num_blue
  
  test  | 4         | 6
  test2 | 3         | 0
  </code></pre>
  
  <p>I can of course select count(*) where type=blue etc but I can't think of how to count multiple types within one query like this.</p>
  
  <p>Thanks!</p>