Friday, March 16, 2012

"Rows into Columns and Columns into Rows"

I have data in a table. I want the values in the rows to place in columns and columns into rows.
Eg:-A table. It consists of three columns and three rows.

name id dept
a 1 x
b 2 y
c 3 z

I want the resultant table should look like this

a b c
1 2 3
x y z

Whether it's possible ?

Check this thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=326394&SiteID=1

You will need to add some value to the rows to uniquely identify the rows when you pivot (but you could do this in a CTE or temp table.

No comments:

Post a Comment