title: oracle transposing text value rows to columns
body: <p>I have a table designed as below in Oracle</p>
  
  <pre><code>+-----------+------+-------+
  |    ID     | TYPE | VALUE | 
  +-----------+------+-------+
  | 1         | A    |     1 |
  | 1         | B    |     2 |
  | 1         | C    |     3 |
  | 2         | A    |     4 |
  | 2         | B    |     5 |
  | 2         | C    |     6 |
  +-----------+------+-------+
  </code></pre>
  
  <p>I need to transpose this table like this</p>
  
  <pre><code>    +-----------+------+-------+-----+
      |    ID     | A    |     B |   C | 
      +-----------+------+-------+-----+
      | 1         | 1    |     2 |   3 |
      | 2         | 4    |     5 |   6 |
      +-----------+------+-------+-----+
  </code></pre>
  
  <p>Below is the sql I wrote using oracle pivot function to transpose these rows into columns. </p>
  
  <pre><code>select * from
  (
  select ID, TYPE, VALUE from table where TYPE in ('A','B','C')
  )
  PIVOT (
  max(value)
  for TYPE in (1 column_a, 2 column_b, 3 column_c)
  )
  </code></pre>
  
  <p>So these are my questions</p>
  
  <ol>
  <li>This returns the result but returns null value even if it's not null. Is it returning NULL because I am using an aggregate function with string value?</li>
  <li>This SQL does not map value to the type. so basically value always need to be tied to type column. Is this doable with PIVOT function? </li>
  </ol>
  
  <p>I am also thinking about just recreating table by using INSERT with SELECT. Please advise if this is doable using PIVOT.</p>