开发者

Merge data for same id

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

How i can show above data in single row as t开发者_StackOverflow社区hose are having same ItemCode?

Kind regards, Om


Try this:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜