Consider an SQL query like this
SELECT Temp.rating, Temp.avgage
FROM (SELECT S.rating, AVG (S.age) AS avgage
FROM Sailors S
GROUP BY S.rating) AS Temp
WHERE Temp.avgage = (SELECT MIN (Temp.avgage)
FROM Temp)
MySQL monitor gives this error:
ERROR 1146 (42S02): Table 'testDB.Temp' doesn't exist
What should I do to avoid this error?
Depending on how you want to handle ties, you could just use:
or the simpler equivalent:
or this one (that shows all tied results):