Explain of sintex

Hey everyone,
Would someone will be able to explain me 2 points:
Why HAVING must come after GROUP BY?
Why we do in HAVING, AVG(budget) and not HAVING avg_budget ?

Thanks a lot !!

SELECT release_year, AVG(budget) AS avg_budget, AVG(gross) AS avg_gross
FROM films
WHERE release_year > 1990
GROUP BY release_year
HAVING AVG(budget) > 6000000

HAVING works on aggregates which GROUP BY define.

SELECT is evaluated after HAVING:

https://blog.sqlauthority.com/2020/11/18/sql-server-logical-processing-order-of-the-select-statement/

hi

thats the WAY they

DESIGNED

it

if they say its CAT its CAT ....... if they says its 145 its 145