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.
Author |
Topic |
on7june
Starting Member
41 Posts |
Posted - 2008-11-10 : 05:55:30
|
How to transpose rows in SQL Server 2000. TblName : ProdMonths Value----------------Jan 1000Feb 6000 Mar 5000Apr 3000. .. .. .. .Dec 2000 I need a select statement which should transpose this data as follows.Months Jan Feb Mar Apr . . . . DecValue 1000 6000 5000 3000 2000Sarvan |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-10 : 05:59:38
|
Read about Cross-ta Reports in sql server help fileMadhivananFailing to plan is Planning to fail |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-10 : 06:05:15
|
[code]SELECT 'Values' AS Month,MAX(CASE WHEN Month='Jan' THEN Value ELSE NULL END) AS Jan,MAX(CASE WHEN Month='Feb' THEN Value ELSE NULL END) AS Feb,MAX(CASE WHEN Month='Mar' THEN Value ELSE NULL END) AS Mar,...MAX(CASE WHEN Month='Dec' THEN Value ELSE NULL END) AS DecFROM Table[/code] |
|
|
on7june
Starting Member
41 Posts |
Posted - 2008-11-10 : 08:06:01
|
Thanks a lot madhi/visakh for the quick turn around. Its working now for me.Sarvan |
|
|
|
|
|