What is the logical processing order of a SELECT statement?
intermediateAnswer
FROM and JOIN, then WHERE, then GROUP BY, then HAVING, then SELECT, then DISTINCT, then ORDER BY, then LIMIT.
This explains several behaviours that otherwise look arbitrary: a SELECT alias is unavailable in WHERE because SELECT runs later, but available in ORDER BY because that runs later still. Window functions are evaluated with SELECT, which is why they cannot appear in WHERE.
Note this is the logical order. The optimiser is free to execute differently as long as the result is equivalent.