My Blog List

hotinit.com. Powered by Blogger.

Search This Blog

Pivot Table Syntax

Monday, 6 June 2011



SELECT
<non-pivoted column>,

[first pivoted column] AS <column name>,

[second pivoted column] AS <column name>,

...

[last pivoted column] AS <column name>

FROM

(<SELECT query that produces the data>)

AS <alias for the source query>

PIVOT

(

<aggregation function>(<column being aggregated>)

FOR

[<column that contains the values that will become column headers>]

IN ( [first pivoted column], [second pivoted column],

... [last pivoted column])

) AS <alias for the pivot table>

<optional ORDER BY clause>;

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

8.6/10