📜  没有聚合的 sql pivot - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:31.654000             🧑  作者: Mango

代码示例1
WITH pivot_data AS
(
SELECT customerid, -- Grouping Column
dbcolumnname, -- Spreading Column
data -- Aggregate Column
FROM pivot2 
)
SELECT customerid, [firstname], [middlename], [lastname]
FROM pivot_data
PIVOT (max(data) FOR dbcolumnname IN ([firstname],[middlename],[lastname])) AS p;