title: Transpose rows to column and join table
body: <p>Hi I have two tables Attribute, Instance</p>
  
  <p><strong>Attribute Table</strong></p>
  
  <pre><code>id  |    key_info   |   value_info
  2   |     amount    |    1009
  2   |   currency    |     USD
  2   |     Level     |    Level 5
  3   |    amount     |     2017 
  3   |   currency    |     CAD
  </code></pre>
  
  <p><strong>Instance Table</strong></p>
  
  <pre><code>id   |  status
  2    | Pending 
  3    | Approved
  </code></pre>
  
  <p>I want to join two tables like this-</p>
  
  <p><strong>New table</strong></p>
  
  <pre><code>id | amount |  currrency | level   | status
  2  |  1001  |     USD    | Level 5 | Pending
  3  |   2017 |     CAD    |         | Approved
  </code></pre>
  
  <p>All the fields in the Attribute and Instance are optional except id.</p>