SQL Server 2005 数据透视表
我想在 SQL Server 2005 中旋转一个列。我很确定有 XML 方法可以完成它,但无法弄清楚。这是一个表格:
ID Class
1 20002
1 20003
1 20004
2 20003
2 20012
期望的值为:
ID Class
1 20002,20003,20004
2 20003,20012
提前致谢
I want to pivot a column in SQL Server 2005. I'm pretty sure there is XML way to get it done but can't figure it out. Here is a table:
ID Class
1 20002
1 20003
1 20004
2 20003
2 20012
Desired value is:
ID Class
1 20002,20003,20004
2 20003,20012
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定 PIVOT(或 UNPIVOT)是您要找的。下面是我需要在查询中获取嵌入的 CSV 列表时使用的一些代码。希望有帮助!
I am not sure PIVOT (or UNPIVOT) are what you are looking for. Below is some code that I use when I need to get a CSV list embedded in a query. Hope it helps!