如果我有一些表格,例如:
[Speed] [Ram] [Whatever] [Other]
S1 R1 W1 O1
S2 R2 W2 O2
S3 R3 W3 O3
我想拥有这样的一切。
[Chr] [Value]
Speed S3
Ram R3
Whatever W3
Other O3
所以我写了以下代码:
SELECT value
FROM
(SELECT speed, ram
FROM pc where code=3) p
UNPIVOT
(value FOR xxx IN
(speed, ram)
)AS unpvt
问题是当我想添加我的第二列 [chr]
SELECT value, chr <---- This does not work
FROM
(SELECT speed, ram, whatever, other
FROM pc where code=3) p
UNPIVOT
(value FOR xxx IN
(speed, ram)
)AS unpvt
UNPIVOT
(chr FOR zzz IN
(speed, ram, whatever, other)
)AS unpvt
我不知道如何在此代码中添加另一列。请任何建议。