Pivot Table in T-SQL 2000

  • I have a table below

    Project # Color

    Project A Red

    Project A Blue

    Project A Green

    Project B Red

    Project B Blue

    Project B Green

    and I need to pivot it to look like:

    Project Color1 Color2 Color3

    Project A Red Blue Green

    Project B Red Blue Green

    Anyone have any ideas?

    Thanks!

    Michael

  • From your sample data, it looks like you have two issues. The first is how to identify which is the first, second or third color. Not sure if that is an actual issue or if your sample data just leaves that out.

    The second is your primary question, involving pivots. Please see the link in my signature for a full explanation of how to do this in SQL 2000. The syntax is easier than pivot too, in my opinion.

    Let us know if you have any questions about how to make it work.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Awesome demonstration... I was almost ready write out the case statements for this?

    Regards - Brad

Viewing 3 posts - 1 through 2 (of 2 total)

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