-1

I have table as

Building    Stairs
A           Two
B.          Three
C.          Two

I need output as

A,C.     Two
B.       Three
Ashish W
  • 3
  • 2
  • 3
    Possible duplicate of [How to make a query with group\_concat in sql server](https://stackoverflow.com/questions/17591490/how-to-make-a-query-with-group-concat-in-sql-server) – S3S Jul 07 '17 at 16:25
  • you can do with STUFF function, FOR XML clause. Search this forum and I'm sure you'll find. – MnM Jul 07 '17 at 16:25
  • Possible duplicate of [Simulating group\_concat MySQL function in Microsoft SQL Server 2005?](https://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-microsoft-sql-server-2005) – Stan Shaw Jul 07 '17 at 16:26

1 Answers1

0

You can do something like this:

SELECT DISTINCT  STUFF((    SELECT ', ' + b.Building
            FROM #table b
            WHERE b.Stairs = a.Stairs               
            FOR XML PATH('') ), 1, 1, '' ) AS Building,
    Stairs
FROM #table a
VDK
  • 573
  • 3
  • 8