Trying to join the tables to get the MIN value of each record, the following table info:
*tblProduct
prodId title description
-------------------------------
1001 title001 desc001
1002 title002 desc002
1003 title003 desc003
*tblPriceVariant
prodId minOrder pricePcs
----------------------------
1001 10 10000
1001 20 7500
1001 30 5000
1002 100 50000
1002 200 40000
1003 10 2500
The query I tried, but the results of the both not what I want:
SELECT tblProduct.prodId, tblProduct.title, tblPriceVariant.pricePcs
FROM tblProduct INNER JOIN tblPriceVariant ON tblProduct.prodId=tblPriceVariant.prodId
And:
SELECT tblProduct.prodId, tblProduct.title, MIN(tblPriceVariant.pricePcs)
FROM tblProduct INNER JOIN tblPriceVariant ON tblProduct.prodId=tblPriceVariant.prodId
Expected result:
prodId title pricePcs
----------------------------
1001 title001 5000
1002 title002 40000
1003 title003 2500
How can I fix it?