How to use GROUP BY to concatenate strings in SQL Server?

前端 未结 20 2630
无人及你
无人及你 2020-11-21 04:33

How do I get:

id       Name       Value
1          A          4
1          B          8
2          C          9

to

id               


        
20条回答
  •  故里飘歌
    2020-11-21 04:42

    This kind of question is asked here very often, and the solution is going to depend a lot on the underlying requirements:

    https://stackoverflow.com/search?q=sql+pivot

    and

    https://stackoverflow.com/search?q=sql+concatenate

    Typically, there is no SQL-only way to do this without either dynamic sql, a user-defined function, or a cursor.

提交回复
热议问题