SELECT a.*
FROM test a
INNER JOIN (
SELECT a.product_code, a.brand, minday, min(price) as minprice
FROM test a
INNER JOIN (
SELECT product_code, brand, MIN(day) minday
FROM test
GROUP BY product_code, brand
) b
ON a.product_code = b.product_code
AND a.brand = b.brand
AND a.day = b.minday
GROUP BY product_code, brand, day) b
ON b.product_code = a.product_code
AND b.brand = a.brand
AND minday = a.day
AND minprice = a.price
WHERE по желанию