Hi All,
I have three tables (Sellers, Products and SellerProductsMap that links them thru Seller_ID and Product_ID)I want to display all the sellers from the seller table and show all the products being sold by each seller. However, my boss wants to have a column that shows if a product sold by a seller is good value for money compared to what price other sellers have for the same product.
This is my faulty attempt:
SELECT d.SellerName, t.ProductName p.Price, ((Highest - p.Price)/PRange) 'Value' FROM
Sellers d
INNER JOIN SellerProductsMap p ON
p.Seller_ID = d.Seller_ID
INNER JOIN Products t ON t.Product_ID = p.Product_ID INNER JOIN (SELECT P.Product_ID, P.Seller_ID, min(P.Price) Lowest, MAX(P.Price) Highest,max(P.Price)-min(P.Price) PRange FROM SellerProductsMap P group by P.Product_ID) R ON
R.Product_ID = p.Product_ID order by d.firstname;
I'm using MySQL. I'm probably overcomplicating things! Hopefully someone knows a simple solution
Thanks in advance!
Daphni,
I have three tables (Sellers, Products and SellerProductsMap that links them thru Seller_ID and Product_ID)I want to display all the sellers from the seller table and show all the products being sold by each seller. However, my boss wants to have a column that shows if a product sold by a seller is good value for money compared to what price other sellers have for the same product.
This is my faulty attempt:
SELECT d.SellerName, t.ProductName p.Price, ((Highest - p.Price)/PRange) 'Value' FROM
Sellers d
INNER JOIN SellerProductsMap p ON
p.Seller_ID = d.Seller_ID
INNER JOIN Products t ON t.Product_ID = p.Product_ID INNER JOIN (SELECT P.Product_ID, P.Seller_ID, min(P.Price) Lowest, MAX(P.Price) Highest,max(P.Price)-min(P.Price) PRange FROM SellerProductsMap P group by P.Product_ID) R ON
R.Product_ID = p.Product_ID order by d.firstname;
I'm using MySQL. I'm probably overcomplicating things! Hopefully someone knows a simple solution
Thanks in advance!
Daphni,