![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table that contains multiple prices for multiple location (yes I know is should have been done with an Xref table or something, but I didn't create it and it's too late to do right now). The records are similar to this... priceID, productID (non-unique), productName, locationID, price 1,100, prod1, 1, $3.00 2,101, prod2, 1, $4.00 3,102, prod3, 1, $2.00 4,101, prod1, 2, $9.00 5,102, prod2, 2, $5.00 6,103, prod3, 2, $8.00 What I would like is for the output is location1Name, Product1Price, Product2Price, Product3Price location2Name, Product1Price, Product2Price, Product3Price location3Name, Product1Price, Product2Price, Product3Price |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
The number of products will be determined by the "items" table. Here is the query as I have it before any rotating and such. The select * is for ease of use while in development. select permutations.location_key, permutations.location_name, permutations.item, permutations.Currency_Code, pp.price -- permutations.*, pp.* from (select * from item cross join location) permutations left join productPrice pp on permutations.item_key = pp.item_key and permutations.location_key = pp.location_key order by permutations.location_key, permutations.Item_key |
![]() |
| Thread Tools | |
| Display Modes | |
| |