ALIAS cannot be used within WHERE clause. It produces an error like this. Just remember it, because it 100% guaranteed situation on your exam.
Even, if you remove double quotes from your ALIAS, the result still the same – it won’t work.
An alias can be used in a query select list to give a column a different name. You can use the alias in ORDER BY clause to refer to the column.
Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the column value may not yet have been determined.
Oracle Query Processing Order
- FROM clause
- WHERE clause
- GROUP BY clause
- HAVING clause
- SELECT clause
- ORDER BY clause
For parsing purposes, the query is evaluated in a particular order. For instance,
FROM is parsed first followed by
WHERE and then followed by
GROUP BY and so on.