Pivot - How to do this?

  • Hi,

    I need help with a sql query, the table looks like the below:

    ID product fldName fldVal

    0001 ABC123 Type1 NULL

    0001 ABC123 Type2 NULL

    0002 ABC128 Type2 78

    0003 ABC129 Type1 MAJOR

    0004 ABC140 Type4 MAJOR

    0006 ABC140 Type4 MAJOR

    0006 ABC141 Type1 NULL

    0008 ABC141 Type1 NULL

    0008 ABC145 Type5 9

    I want to pivot it so that it looks like this:

    ID product Type1 Type2 Type4 Type5

    1 ABC123 NULL

    1 ABC123 NULL

    2 ABC128 78

    3 ABC129 MAJOR

    4 ABC140 MAJOR

    6 ABC140 MAJOR

    6 ABC141 NULL

    8 ABC141 NULL

    8 ABC145 9

    How do i do a query for this, or how do i do this in ssis?

    Thanks

  • Please have a look at the CrossTab article referenced in my signature. It will show you an easier way than the PIVOT operator...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

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

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