I have an item with 4 units of measure and each one has a different size. I want to get the UOMs as column names with the size listed below so that I have only one line for the result. I have tried a pivot but I get NULL values. Here is what I have so far.[code="sql"]CREATE TABLE test_uom (item_id varchar(10), unit_of_measure varchar(5), unit_size decimal(8,0))INSERT INTO test_uom (item_id, unit_of_measure, unit_size)VALUES ('WIRE', 'CTN', 2000),('WIRE', 'RL', 500),('WIRE', 'FT', 1),('WIRE', 'M', 1000)SELECT item_id , UOM , SizeFROM (SELECT item_id , unit_of_measure , unit_size FROM test_uom ) APIVOT ( MIN(unit_size) FOR unit_of_measure IN ([UOM], [Size]) ) AS Pvt[/code]
↧