title: Error converting data type nvarchar to int in multiple Pivot on same column SQL
body: <p>I am trying to use multiple pivot in a single query on same column.
  Since i am using same column "month" for all the pivot's, i have added column header to the select list and have added different alias name. Month column has int datatype value. Below is the code:</p>
  
  <pre><code>    Select * FROM  
      (
      SELECT 
      [team], 
      Count_O,
      Count_Of_OA,
      Avg,
      [month]+ '_a'  as month_a, 
      [month] + '_b' as month_b,
      [users]  
      FROM [#Temp]
      ) AS X 
  
      PIVOT  
  (  
      MAX(Count_OA)
      FOR [month_a] IN ([4_a], [5_a], [6_b])  
  )   AS PivotTable1
  
  PIVOT  
  (  
      MAX(Count_O)
      FOR [month_b] IN ([4_b], [5_b], [6_b])  
  )   AS PivotTable2
  </code></pre>
  
  <p>When i execute this, I get the below error:
  Msg 8114, Level 16, State 1, Line 44
  Error converting data type nvarchar to int.</p>
  
  <p>Any inputs would be much appreciated.</p>