SQL Select Command Help

  • I have a table that has data that appears like:

    ID Date (YYYYMM)

    01 200811

    01 200808

    01 200712

    01 200704

    01 200607

    01 200603

    01 199805

    02 200803

    02 200704

    02 200611

    03 200705

    03 200309

    03 199912

    03 199607

    03 199408

    ...

    I want to rearrange the data so it appears in a table or result set like this:

    ID D1 D2 D3 D4 D5 D6

    01 200811 200808 200712 200704 200607 200603

    02 200803 200704 200611

    03 200705 200309 199912 199607 199408

    Can I do this without looping through all the ID's?

    Thank you,

  • Read Books Online, specifically look up the PIVOT command.

  • I am using SQL 2000 and PIVOT is in 2005 and 2008. Is there another way?

  • Sorry, but you posted your question in a SQL Server 2005 forum, so you got a SQL Server 2005 answer.

  • Ahhh, that would explain it. Sorry. I'll repost in a SQL 2000 forum.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply