选择行作为列

时间:2016-04-26 03:09:29

标签: sql pivot-table

我有一个带有以下值的简单表

enter image description here

我希望输出为:

enter image description here

1 个答案:

答案 0 :(得分:1)

SELECT Name, Filter1, Filter2
FROM
(SELECT Name, Attribute, Value
    FROM PivotEx) AS SourceTable
PIVOT
(
MAX(Value)
FOR Attribute IN (Filter1, Filter2)
) AS PivotTable