Tuesday 15 June 2010

SQL 2005 Pivot Query -


I'm trying to get a hold on the pivot query syntax.

I have approximately 20 field values ​​of the total data associated with 1 field, which is the range for those 20 fields (the column by field means).

It looks like

  category1 column1 column2 column3 category 2 column1 column2column3  

and so on ... < / P>

What I'm trying to do turns out those results to come out in this way

  category 1 category 2 category 3 column 1 column 1 column 1 Column 2 Column 2 Column 2 Column 3 Column 3 Column 3  

My query looks like this

  SELECT TOP (3) range FROM (from SELECT category Table) P POVOT (AGG (column 1) as column 1, AG VI (column 2) column as 2, Ajiji (column 3)) class category as column 3) PST;  

I am running SQL Server 2005. Thanks for any help or suggestions!

I think that you really want.


No comments:

Post a Comment