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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.