Here is an article that is very helpful in this matter: Avoid Transact-SQL's Column Alias Limitations
- MS SQL only allow alias in SELECT and ORDER BY
- Use sub-query, can help in some cases to re-use column alias
1046: Type was not found or was not a compile-time constant: ?????.