tsql - How to refer to a variable create in the course of executing a query in T-SQL, in the WHERE clause? -
what title says, really. if select [statement] whatever, why can't refer whatever column in body of clause? there kind of workaround? it's driving me crazy. as far i'm aware, can't directly in sql server. if have use column alias in clause, can this, seems overkill use subquery alias: select * ( select [yourcolumn] youralias, etc... whatever ) yoursubquery youralias > 2 you're better off using contents of original column in clause.