title: Extract data from multiple tables
body: <p>I have 2 tables </p>
  
  <p>TABLE A  </p>
  
  <pre><code>INV    AMT   DISC
  1001  1500    150
  1002  3000    300
  </code></pre>
  
  <p>TABLE B  </p>
  
  <pre><code>INV  DESC        AMT
  1001 CHARGES     100
  1001 FREIGHT      30
  1001 INSURANCE    20
  1002 CHARGES     215
  1002 FREIGHT      32
  1002 INSURANCE    25
  </code></pre>
  
  <p>For Table B, I used the SQL here to convert row to column format:</p>
  
  <pre><code>SELECT t.inv,
           MAX(CASE WHEN t.description = 'CHARGES' THEN t.amount ELSE NULL END) AS charges,
           MAX(CASE WHEN t.description = 'FREIGHT' THEN t.amount ELSE NULL END) AS freight,
           MAX(CASE WHEN t.description = 'INSURANCE' THEN t.amount ELSE NULL END) AS insurance
      FROM TABLE B
  GROUP BY t.inv
  ORDER BY t.inv
  </code></pre>
  
  <p>How can I combine the data into this format using SQL:</p>
  
  <pre><code>INV     AMT   DISC    CHARGES FREIGHT INSURANCE
  1001   1500    150      100      30       20
  1002   3000    300      215      32       25
  </code></pre>
  
  <p>Thanks.</p>