Interview-join

0

Please login or register to vote for this query.

(click on this box to dismiss)

Home Improvement

Q&A for contractors and serious DIYers

CREATE table #ITEM_VALUE
    ([ITEM_ID] int, [ATTRIBUTE_ID] int, [VALUE] varchar(13))
;
    
INSERT INTO #ITEM_VALUE
    ([ITEM_ID], [ATTRIBUTE_ID], [VALUE])
VALUES
    (1001,2001,'K3401'),
    (1001,2002,'Coffee Cup'),
    (1001,2003,'10 oz'),
    (1001,2004,'$2.15'),
    (1001,2005,'$1.85' ),
    (1002,2001,'K3402'),
    (1002,2003,'6 oz'),
    (1002,2004,'$4.00'),
    (1002,2005,'$3.85' ),
    (1003,2001,'K3403'),
    (1003,2002,'Mug'),
    (1003,2003,'4 oz'),
    (1003,2004,'$3.00'),
    (1004,2001,'K3404'),
    (1004,2002,'Spoon'),
    (1004,2003,'NA'),
    (1004,2004,'$1.00'),
    (1004,2005,'$0.85' )
;


SELECT [2001] as [Item #], [2002] as [Description], [2003] as [Capacity], [2004] as [List Price], [2005] as [Sale Price]
FROM   #ITEM_VALUE 
PIVOT
(
       max(value)
       FOR [ATTRIBUTE_ID] IN ([2001], [2002], [2003], [2004], [2005])
) AS P

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results