Transposing data from Columns to Rows

  • I have data in a table as below.

    IDData

    1A

    1B

    1A

    2C

    3A

    3A

    I want to return this

    IDData

    1A,B

    2C

    3A

    How do I return a distinct value for the Data Column that is comma delimited? example ID 1 has A in the Data field twice but I only want it once.

  • Why not have the front-end do that kind of thing? SQL isn't all that good at string manipulation.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Are you using SS2K or SS2K5?

    Based on the forum you posted in I assume SS2K, but need to make sure before posting a non-working/inefficient solution.



    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]

  • See if this article does not give you what you need.

    http://www.sqlservercentral.com/articles/Test+Data/61572/

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • Yes we use 2000.

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

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