Logical query processing evaluates FROM -> ON -> WHERE -> SELECT -> ORDER BY.
In query 1, database query engine wants Actual column name to process the where condition and it is not present, that's why it is failed.
In query 2, query engine can use column alias to get the required information, hence it is working fine.
commented on May 9 2012 6:33AM