title: How transpose a table using SQL?
body: <p>I have a table like this:</p>
  
  <pre><code>id | P  | C | A |  B
  --------------------
  1  |100 |3  |a1 | b1
  2  |101 |3  |a2 | b2
  3  |102 |3  |a3 | b3
  4  |103 |3  |a4 | b4
  5  |100 |4  |a5 | b5 
  6  |101 |4  |a6 | b6 
  7  |102 |4  |a7 | b7
  8  |103 |4  |a8 | b8
  </code></pre>
  
  <p>I want to get a new transposed structure like this:</p>
  
  <pre><code> P  |_3A | _3B |_4A | _4B   
  -------------------------
  100 | a1 |  b1 | a5 | b5
  101 | a2 |  b2 | a6 | b6  
  102 | a3 |  b3 | a7 | b7
  103 | a4 |  b4 | a8 | b8
  </code></pre>
  
  <p>As you can see ,new field names have been extracted from C field in the original table.
  Is there any way to do this using SQL?</p>