Separate values with comma

  • Ex:

    Title date name country

    Title1 23/07/09 Dan Norway

    Title1 23/07/09 Trevor Norway

    Title2 23/07/09 Ingra Norway

    Above shows the table output. How do I create an SQL statement that will group and then separate the 'Name' with a comma as shown below. Please note that they have the same title 'Title 1'

    Title date name Country

    Title1 23/07/09 Dan, Trevor Norway

    Title2 23/07/09 Ingra Norway

    I am able to peform the grouping but the separation by comma is a real issue for me

    Please any help will be highly appreciate

  • This SSC post is similar to your situation, I believe. This is just trying to separate with a space but you could adjust the query to insert comma.

    Trying to separate a name field into two columns

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton

  • Hi Shawn,

    Thanks for the info, However it doesn't really help as I am grouping the records but then trying to separte the distinct names by a comma

    Ex:

    Title date name country

    Title1 23/07/09 Dan Norway

    Title1 23/07/09 Trevor Norway

    Title2 23/07/09 Ingra Norway

    Above shows the table output. What I am trying to do is group by title, date, country and then separte the name values (Dan and Trevor) by a comma so that the end product is as below

    Title date name Country

    Title1 23/07/09 Dan, Trevor Norway

    Title2 23/07/09 Ingra Norway

    I hope this sheds more light on my problem

    Cheers

    Nneka

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

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