0

He

Anyone know how to get the same ids here into one row along with the other column after the comma, so group by id where there is another record from other column.

   SELECT 
   CONCAT(p.ID, ', ', '', s.[value]) 'id, OtherColumn'

  FROM [Test].[Person].[Name] s
  INNER JOIN [Test].[Person].[Nameref] sr ON s.Id = sr.ID
  INNER JOIN [Test2].[Test2] p ON sr.Id = p.ID
   GROUP BY p.ID, s.value

1, 4GL
1, Web
1, CCS

Needs to be:

1 , 4GL, Web, CCS

Thanks

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
sz1
  • 72
  • 1
  • 8
  • 1
    This has been asked and answered literally thousands of times. – Sean Lange Sep 28 '17 at 15:59
  • Simulate oracle `ListAgg()` using forXmlPath here's an example: https://stackoverflow.com/questions/15477743/listagg-in-sqlserver or use `string_agg()` if you have 2017. – xQbert Sep 28 '17 at 16:00
  • I think searching for "Building a comma separated list?" on this site should help, or maybe any one of the other 999 other posts that Sean mentions... – Lee Sep 28 '17 at 16:12
  • I don't want to show all the values for value just the ones that person nameref has assigned. – sz1 Sep 28 '17 at 16:38

0 Answers0