If you want to search database based on result of aggregate function, you should use
HAVING clause[
^]!
But in your case i would suggest to use
variables[
^]:
SELECT @minprice = MIN(unitprice) FROM rm_price;
SELECT @maxprice = MAX(unitprice) FROM rm_price;
SELECT rmname, @minprice as MinPrice, (SELECT inv_date FROM rm_price WHERE unitprice = @minprice AND rmname = t.rmname) AS MinDate,
@maxprice AS MaxPrice, (SELECT inv_date FROM rm_price WHERE unitprice = @minprice AND rmname = t.rmname) AS MaxDate
FROM rm_price AS t;
It should execute quite fast.