title: T-SQL pivot with more then one non-pivot columns
body: <p>I have several columns and making pivot. I want to have multiple non-pivot columns and to make pivot using the last one. In the original specification <a href="http://msdn.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx" rel="nofollow">here</a> it is shown that you can have only one non-pivot column.</p>
  
  <pre><code>SELECT &lt;non-pivoted column&gt;,
  
      [first pivoted column] AS &lt;column name&gt;,
  
      [second pivoted column] AS &lt;column name&gt;,
  
      ...
  
      [last pivoted column] AS &lt;column name&gt;
  
  FROM
  
      (&lt;SELECT query that produces the data&gt;)
  
      AS &lt;alias for the source query&gt;
  
  PIVOT
  
  (
  
      &lt;aggregation function&gt;(&lt;column being aggregated&gt;)
  
  FOR
  
  [&lt;column that contains the values that will become column headers&gt;]
  
      IN ( [first pivoted column], [second pivoted column],
  
      ... [last pivoted column])
  
  ) AS &lt;alias for the pivot table&gt;
  
  &lt;optional ORDER BY clause&gt;;
  </code></pre>
  
  <p>Is there a way to have more non-pivot columns, because it is pivoting my data using all columns after the first one.</p>