Link to home
Start Free TrialLog in
Avatar of RStuppi
RStuppi

asked on

Flatten a table

I'm using SQL Server 2K and I need to flatten a table for a report.

The table looks like this:

ID            PARENTID           StartDate
_________________________________
1               1                       1/1/2006
2               1                       2/1/2006
3               1                       3/1/2006
4               2                       1/1/2005
5               2                       2/1/2005
6               3                       1/1/2004
7               3                       2/1/2004
8               3                       3/1/2004
9               3                       4/1/2004


I need a query or procedure that produces this:

PARENTID           StartDate1      StartDate2    StartDate3     StartDate4
__________________________________________________________
1                       1/1/2006        2/1/2006        3/1/2006       NULL
2                       1/1/2005        2/1/2005        NULL             NULL
3                       1/1/2004        2/1/2004        3/1/2004       4/1/2004

Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland 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