New: Intelligent Flashcards spaced-repetition decks for every topic, built to make things actually stick.
Why can a SELECT-list alias like SELECT salary * 12 AS annual be used in ORDER BY but not in WHERE?
SELECT salary * 12 AS annual
ORDER BY
WHERE
WHERE only accepts column names from the FROM tables and rejects all expressions
Aliases are stored as strings and need an explicit cast before WHERE can read them
WHERE is logically processed before SELECT, so the alias does not exist yet