Getting values from multiple rows into single row

  • I have a table A that contains a ID and value column, the primary key is set on this 2 columns.

    Table A

    Column ID varchar(10)

    Column Value int

    Values

    ID Value

    A100 100

    B100 100

    A100 200

    B100 300

    A100 400

    C100 500

    I want a sql that display values in the following format

    ID Result

    A100 100,200,400

    B100 100,300

    C100 500

    Can any one help me to generate this report

    Thanks,

  • Hopefully this will get you started

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    Dave

  • I guess it's more an issue of getting a comma delimited list instead of pivoted data.

    If that's the case, the FOR XML PATH approach as demonstrated here might be more towards the expected result.



    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 3 posts - 1 through 2 (of 2 total)

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