I have a data table like:
- PK_table - merchantName - price - Product
- 1 - argos - 7 - 4
- 2 - comet - 3 - 4
- 1 - Dixon - 1 - 3
- 1 - argos - 10 - 4
I want to choose the minimum price for the product and the corresponding seller in mysql.
I tried:
SELECT Product, merchantName, min(price)
FROM a_table
GROUP BY product
however, the returned result is incorrect because it selects the seller’s first name and not the corresponding MIN merchant.
how do you do it
source
share