Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我什至不知道如何问这个问题:
我有一个看起来像这样的表:
我想通过使用别名或重新插入来选择颜色?不确定,但我需要它看起来像这样。
我怎样才能做到这一点?
太感谢了。
更新:这是针对 SQL Server 2012
对于 SQL 服务器
select C.UserID, stuff( ( select ', ' + t.Color from table1 as t where t.UserID = C.UserID order by t.Color for xml path(''), type ).value('.', 'nvarchar(max)') , 1, 2, '') from table1 as C group by C.UserID
SQL 小提琴