SELECT AVG(age) FROM persons HAVING age >= 18
is incorrect because having clause can only be used with fields specified in GROUP BY clause or aggregate operators' results.
SELECT AVG(age) FROM persons WHERE age >= 18 GROUP BY name
will return average age of people with the same name.
SELECT AVG(age) FROM persons HAVING AVG(age) >= 18
will be executed without errors, but will return a completely different ersult
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать