SSIS:PIVOT,UNPIVOT有两个标题行

时间:2014-10-28 01:53:51

标签: sql sql-server pivot unpivot

我有一个数据表,不幸的是我有两个标题行:

Measures    Product     4Weeks10-19-14  4Weeks10-19-14  Week09-28-14  Week09-28-14
Measures    Product     Current         Change vs YA    Current       Change vs YA
Avg Units   Apples      22.93           -1.68           22.30         -2.96
Avg Units   Oranges     3.68            0.76            3.00          -0.13
Avg Units   Plums       13.93           0.87            13.66         -0.27
Avg Units   Pineapples  2.49            -0.66           2.48          -0.65
Avg Units   Hot Pockets 28.59           1.05            28.80         0.29

我想将第一个标题行转到一个列,如下所示:

Measure     Product     Time            Current  Change vs YA

Avg Units   Apples      4Weeks10-19-14  22.93   -1.68
Avg Units   Oranges     4Weeks10-19-14  3.68    0.76
Avg Units   Plums       4Weeks10-19-14  13.93   0.87
Avg Units   Pineapples  4Weeks10-19-14  2.49    -0.66
Avg Units   Hot Pockets 4Weeks10-19-14  28.59   1.05
Avg Units   Apples      Week09-28-14    22.30   -2.96
Avg Units   Oranges     Week09-28-14    3.00    -0.13
Avg Units   Plums       Week09-28-14    13.66   -0.27
Avg Units   Pineapples  Week09-28-14    2.48    -0.65
Avg Units   Hot Pockets Week09-28-14    28.80   0.29

我过去曾使用过UNPIVOT(对不起,只有一次),但我不知道如何处理这个问题。

提前感谢您的帮助!

0 个答案:

没有答案