Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help to pivot table

Author  Topic 

anujpratap84
Starting Member

45 Posts

Posted - 2012-04-11 : 04:36:09
Hi All,

I want to pivot my resultant table.
Below is the sample result set.

Sno RN Tran Sale SPG Group
1 12 12 44 55 51
2 18 14 47 59 56
3 13 12 44 55 5
4 12 12 44 5 56
5 12 12 44 55 2

I want to transform the table
Then Sno 1 2 3 4 5 will be the column

Please help



Anuj Pratap Singh

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-12 : 00:35:03
what all values you need to pivot? can you show how output will be for above data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

anujpratap84
Starting Member

45 Posts

Posted - 2012-04-12 : 01:13:17
I want output like below format.

Sno 1 2 3 4 5
Rn 12 18 13 12 12
Tran 12 14 12 12 12
Sale 44 47 44 44 44
......



quote:
Originally posted by visakh16

what all values you need to pivot? can you show how output will be for above data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Anuj Pratap Singh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-04-12 : 01:20:22
see

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=173416

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vinu.vijayan
Posting Yak Master

227 Posts

Posted - 2012-04-12 : 05:34:00
Try this link For Pivot/Unpivot:

[url]http://msdn.microsoft.com/en-us/library/ms177410.aspx[/url]

Look at the examples. Hope that would help.

Vinu Vijayan

N 28° 33' 11.93148"
E 77° 14' 33.66384"
Go to Top of Page
   

- Advertisement -