title: SQL Transpose table - sqlserver
body: <p>i have the following table</p>
  
  <pre><code>create table mytab (
    mID int primary key,
    pname varchar(100) not null,
    pvalue varchar(100) not null
  )
  </code></pre>
  
  <p>example data looks like</p>
  
  <pre><code>mID     |pname  |pvalue
  -----------------------
  1       |AAR    |   2.3
  1       |AAM    |   1.2
  1       |GXX    |     5
  2       |AAR    |   5.4
  2       |AAM    |   3.0
  3       |AAR    |   0.2
  </code></pre>
  
  <p>I want to flip the table so that i get</p>
  
  <pre><code>mID     | AAR   |   AAM |    GXX|
  ---------------------------------
  1       | 2.3   |   1.2 |      5|
  2       | 5.4   |   3.0 |      0|
  3       | 0.2   |     0 |      0
  </code></pre>
  
  <p>Is this somehow possible and if so, is there a way to create a dynamic query because there are lots of these pname pvalue pairs</p>