Currently, I have a table that tracks product inventory locations using the following table:
ProductID(PK) Location(PK) BIN1 BIN2
1000 EAST XRZY CCAB
1000 WEST AAAA NULL
I'm attempting to UNPIVOT the data into the following:
ProductID EAST_BIN1 EAST_BIN2 WEST_BIN1 WEST_BIN2
1000 XRZY CCAB AAAA NULL
Note that the location column has been PIVOTed into part of the BIN value field.
However, I've found that if I pivot the data, I'm unable to combine it with the BIN fields. PIVOT simply aggregates (using MAX) the BIN values into one field, while UNPIVOT just transforms the BIN* fields into rows.
What am I missing in terms of transforming the data above?
Any help would be greatly appreciated!