<SELECT query that produces the data>)
<alias for the source query>
<column being aggregated>)
<column that contains the values that will become column headers>]
<alias for the pivot table>
<optional ORDER BY clause>;
Using PIVOT and UNPIVOT operators you transform a table by shifting the rows (column values) of a table to columns and vise-versa. As part of this transformation aggregation functions can be applied on the table values.