I have a table of data like so :
- PK_table - merchantName - price - Product
- 1 - argos - 7 - 4
- 2 - comet - 3 - 4
- 1 - Dixon - 1 - 3
- 1 - argos - 10 - 4
I wish to select the minimum price for a product and the corresponding merchant in mysql.
I tried:
SELECT Product, merchantName, min(price)
FROM a_table
GROUP BY product
however the result returned is incorrect since it chooses the first merchant name and not the corresponding merchant of the MIN.
how do you do it?