I have a database with Mountains, with their names and heights. I want a query that gives me the names of the montains that differ less than 100 meters height from the average of all
mountains.
I have tried:
SELECT Name FROM mountain
WHERE Height BETWEEN ABS((AVG(Height)) - 100) AND ABS(AVG(Height))
But it is not working, any ideas? 🙂
>Solution :
You need a subquery to get the average mountain height:
SELECT Name FROM mountain
WHERE (select AVG(Height) from mountain) BETWEEN Height - 100 and Height + 100