【发布时间】:2015-08-06 17:22:05
【问题描述】:
我在数据库中有一些项目,格式如下:
ID|ColName|ColValue
-------------------
1 |A |1testa
1 |B |1testb
1 |C |1testc
1 |D |1testd
2 |A |2testa
2 |D |2testd
我需要以下表格的数据:
ID| A | B | C | D
1 | 1testa | 1testb | 1testc | 1testd
2 | 2testa | NULL | NULL | 2testd
我曾尝试在T-SQL 中使用PIVOT,但它需要聚合函数作为参数,我不想提供。
我怎样才能做到这一点。
【问题讨论】:
标签: sql sql-server tsql pivot