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 |
harmonium
Starting Member
5 Posts |
Posted - 2008-11-24 : 13:59:31
|
I have a table that has data that appears like:ID Date (YYYYMM)01 20081101 20080801 20071201 20070401 20060701 20060301 19980502 20080302 20070402 20061103 20070503 20030903 19991203 19960703 199408...I want to rearrange the data so it appears in a table or result set like this:ID D1 D2 D3 D4 D5 D601 200811 200808 200712 200704 200607 200603 02 200803 200704 20061103 200705 200309 199912 199607 199408Can I do this without looping through all the ID's?Thank you, |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-11-24 : 14:06:58
|
Will data be consistent? Use cross tabs or Dynamic cross tabs query for it. |
|
|
harmonium
Starting Member
5 Posts |
Posted - 2008-11-24 : 14:23:17
|
quote: Originally posted by sodeep Will data be consistent? Use cross tabs or Dynamic cross tabs query for it.
ID will be consistent, Date format will be consistent, the number of Dates to ID will not be consistent. I am looking into cross tabs and then Dynamic cross tabs now. |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-11-24 : 18:29:01
|
Read this:http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/dynamic-crosstab-with-multiple-pivot-columns.aspx |
|
|
|
|
|