mrj1976
asked on
Convert Columns To Rows
I have a table with 5 columns and 5 rows as below:
Comany HeadcountStart Starters Leavers HeatcountEnd
------ -------------- -------- ------- ------------
AAA 500 10 5 505
BBB 180 5 0 185
CCC 225 15 5 235
DDD 50 3 0 53
EEE 200 0 5 195
I need to convert the data in the columns into rows as follows:
Company AAA BBB CCC DDD EEE
HeadcountStart 500 180 225 50 200
Starters 10 5 15 3 0
Leavers 5 0 5 0 5
HeadcountEnd 505 185 235 53 195
The number of rows and columns are static.
I'm using SQL 2000.
Thanks for help.
Comany HeadcountStart Starters Leavers HeatcountEnd
------ -------------- -------- ------- ------------
AAA 500 10 5 505
BBB 180 5 0 185
CCC 225 15 5 235
DDD 50 3 0 53
EEE 200 0 5 195
I need to convert the data in the columns into rows as follows:
Company AAA BBB CCC DDD EEE
HeadcountStart 500 180 225 50 200
Starters 10 5 15 3 0
Leavers 5 0 5 0 5
HeadcountEnd 505 185 235 53 195
The number of rows and columns are static.
I'm using SQL 2000.
Thanks for help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ptjcb:
http://sqlserver2000.databases.aspfaq.com/how-do-i-create-a-cross-tab-or-pivot-query.html
http://snippets.dzone.com/posts/show/2000
There are many links to walk you through how to do pivot tables using SQL 2000 t-sql.