Link to home
Start Free TrialLog in
Avatar of mrj1976
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.
ASKER CERTIFIED SOLUTION
Avatar of ptjcb
ptjcb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of openshac
openshac

Here's a copy of the accepted solution which said was Force Closed:

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.