ItemCode AttributeCode AttributeValue ----------- -------------------- ---------------- ITEM-000001 BUTTONS 2B ITEM-000001 COLOR NAVY ITEM-000001 FABRIC A-W ITEM-000001 LAPEL NOTCH ITEM-000001 PATTERN STRIPE ITEM-000001 SEASON A6 ITEM-000001 SUITSTYLE SB ITEM-000001 VENT NONE
我如何在单行显示上面的数据,因为它们具有相同的ItemCode? p>
亲切的问候, 嗡
答案 0 :(得分:1)
试试这个:
SELECT ItemCode,
(SELECT AttributeValue FROM Table x WHERE x.ItemCode = t.ItemCode AND x.AttributeCode = 'BUTTONS') as [Buttons],
(SELECT AttributeValue FROM Table x WHERE x.ItemCode = t.ItemCode AND x.AttributeCode = 'COLOR') as [Color],
..... repeat for all .....
FROM Table t
GROUP BY ItemCode