This is table 'VendorItemPricing'.
ItemID VendorName VendorPrice
122 HP 215.13
122 IBM 264.41
122 Microsoft 257.65
I used this query to get make rows as columns.
Select ItemID,
[HP] As HPPrice ,
[Apple] As ApplePrice,
[Microsoft] As MicrosoftPrice,
[IBM] As IBMPrice from (
select ItemID,VendorName,VendorPrice from VendorItemPricing where ItemID = 122)A
PIVOT(MAX(VendorPrice) FOR VendorName IN ([HP],[Apple],Microsoft,IBM))P
And this's the output as I expected.
ItemID HPPrice ApplePrice MicrosoftPrice IBMPrice
122 215.13 NULL 257.65 264.41
This is my table 'MasterItems', and i used this query to get below results.
select ItemID, ItemPartNumber, ItemDescription, CreatedDate, InitialPrice from MasterItems where ItemID = 122
This's the result probably.
ItemID ItemPartNumber ItemDescription CreatedDate InitialPrice
122 AB246VB Volt Fuser Kit 2015-05-15 17:17:32.940 215.14
Is it possible to join both results and get results like below?
ItemID ItemPartNumber ItemDescription CreatedDate InitialPrice HPPrice ApplePrice MicrosoftPrice IBMPrice
122 AB246VB Volt Fuser Kit 2015-05-15 17:17:32.940 215.14 215.13 NULL 257.65 264.41