title: Use row values as columns in PostgreSQL
body: <p>I have the following <code>brands</code> table with <code>total</code> sales per <code>month</code> as a result of a previous query:</p>
  
  <pre><code> id  |   date   | total
  -----+----------+------
   123 | Apr-2012 | 100
   123 | Mar-2012 | 150
   123 | Jan-2012 | 500
   987 | Apr-2012 | 5
   987 | Mar-2012 | 0.10
   987 | Feb-2012 | 8
  </code></pre>
  
  <p>I am looking to achieve the following:</p>
  
  <pre><code> id  | Apr-2012 | Mar-2012 | Feb-2012 | Jan-2012
   123 | 100      | 150      | 0        | 500
   987 | 5        | 0.10     | 8        | 0
  </code></pre>
  
  <p>How do I use the <code>date</code> values as columns and be able to fill in missing dates with 0 totals?</p>