1

次の選択ステートメントを作成しました。

SELECT     x.Code, y.AttributeCode, y.Value
FROM         x INNER JOIN
                      y ON x.Id = y.ItemCodeId
WHERE  (AttributeCode = 'Length' or AttributeCode = 'Width' or AttributeCode = 'Height')

結果は次のように表示されます。

Code    AttributeCode   Value
1000165 Width              4
1000165 Length           19.5
1000165 Height            3.8
1000173 Length             3
1000173 Height             8
1000173 Width              5

そして、次のように表示したいと思います。

100165 Width 4 Length 19.5 Height 3.8
100173 Width 5 Length 3    Height 8

これが繰り返しである場合は申し訳ありませんが、この質問に答えるために他のいくつかの回答を調べました(MS SQLは私にとって初めてなので、検索時に適切な言語を使用していない可能性があります)。

4

2 に答える 2

0
SELECT x.Code, a.AttributeCode, a.Value, b.AttributeCode, b.Value, c.AttributeCode, c.Value
FROM x
INNER JOIN y a ON x.Id = a.ItemCodeId
INNER JOIN y b ON x.Id = b.ItemCodeId
INNER JOIN y c ON x.Id = c.ItemCodeId
WHERE (a.AttributeCode = 'Width') and (b.AttributeCode = 'Length') and (c.AttributeCode = 'Height') 
于 2013-07-26T23:23:53.147 に答える