Find those ratings for which the average age is the minimum over all ratings
Aggregate operations cannot be nested! WRONG:
WHERE S.age = (SELECT MIN (AVG (S2.age)) FROM Sailors S2)
SELECT Temp.rating, Temp.avgage
FROM (SELECT S.rating, AVG (S.age) AS avgage
GROUP BY S.rating) AS Temp
WHERE Temp.avgage = (SELECT MIN (Temp.avgage)
- Correct solution (in SQL/92):