Home Forums SQL Server 2008 SQL Server Newbies Using coalesce in a single table RE: Using coalesce in a single table
Sue_H
SSC Guru
Points: 90860
More actions
August 24, 2016 at 12:30 pm
#1897298
SELECT ID ,
Brand = STUFF(( SELECT',' + Brand
FROM YourTable AS P2
WHERE P2.ID = P1.ID
ORDER BY Brand
FOR XMLPATH('')
), 1, 1, '')
FROM YourTable AS P1
Group by ID;