たとえば、テーブルがある場合:
[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
問題は、2 番目の列 [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
このコードに別の列を追加する方法がわかりません。アドバイスをお願いします。