title: Postgres dynamic column headers (from another table)
body: <p>Just a silly example:</p>
  
  <blockquote>
    <p>Table A:</p>
    
    <ol>
    <li>eggs</li>
    <li>bread</li>
    <li>cheese</li>
    </ol>
    
    <p>Table B (when they are eaten):</p>
    
    <ol>
    <li>Egg | date</li>
    <li>Bread | date</li>
    <li>Egg | date</li>
    <li>cheese | date</li>
    <li>Bread | date</li>
    </ol>
  </blockquote>
  
  <p>For statistics purpouses, i need to have statistics per date per food type in a look like this:</p>
  
  <p>Table Statistics:</p>
  
  <pre><code>             egg   |   bread   |   cheese
  
  date1         2          1            0    
  
  date2         6          4            2
  
  date3         2          0            0
  </code></pre>
  
  <p>I need the column headers to be dynamic in the report (if new ones are added, it should automatically appear).</p>
  
  <p>Any idea how to make this in postgres?</p>
  
  <p>Thanks.</p>