SQL Question

I need to group 2 rows two 1 and concatenate values of one column in SQL SERVER 2008

so this is the situation,i have this table with multiple records but a few records have the same values with only one column being different

ID NAME SELCODE RANGE
111 DANIEL 123123 YES
111 DANIEL 123123 NO


i want to merge this difference into one row but with both values from the
RANGE
column, as follows.

ID NAME SELCODE RANGE
111 DANIEL 123123 YES/NO

Answer

There are definitely a lot of examples of this around but here is one way you can do it:

SELECT
    DISTINCT
    t.ID
    ,t.Name
    ,t.SELCODE
    ,STUFF(
        (SELECT '/' + RANGE
        FROM
            Table t2
        WHERE
          t.Id = t2.ID
          AND t.Name = t2.Name
          AND t.SELCODE = t2.SELCODE
        FOR XML PATH(''))

        ,1,1,'') as RANGE
FROM
    Table t