title: SQL Server: how to create a table from a pivot table?
body: <p>I have a table like this,</p>
  
  <p><a href="https://i.stack.imgur.com/tJRjL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tJRjL.png" alt="enter image description here"></a></p>
  
  <p>and I have pivoted it to the following with the code,</p>
  
  <pre><code>select * 
  from 
  (
    select  *
    from table1
  ) a
  pivot 
  (
  avg(col3)
   for col2 in ([a],[b],[c],[d])
  ) as pv;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/r2A2R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r2A2R.png" alt="enter image description here"></a></p>
  
  <p>How can I create a new table from the pivot table pv? I have tried select * into newTable, but it doesn't seem to work.</p>