I have this SQL Server query:
SELECT [VendorID], [QuotedAmount]
FROM [tbl_Vendor_Quotation]
WHERE [ProductID] = 1
ORDER BY vendorID
This query returns data like this:
VendorID QuotedAmount
-------------------------
1 1000000
1 900000
1 750000
1 720000
1 650000
2 1250000
2 1200000
3 1500000
4 1000000
4 970000
4 950000
5 1450000
6 1450000
8 1200000
I want to pivot this such a way that it will come up as per the below table
VendorId R0 R1 R2 R3 R4
----------------------------------------------------------
1 1000000 900000 750000 720000 650000
2 1250000 1200000
3 1500000
4 1000000 970000 950000
5 1450000
6 1450000
8 1200000
R0, R1---Rn Shows Maximum times VendorID
Repeated with QuotedAmount
.In this case R0,R1 ---R4(5 times) as VendorID 1 is maximum time repeated 5 times.
I followed a lot of example to make it but didn't get successes. Please help me.