Original address: http://www.cnblogs.com/dwfbenben/p/3307941.html
When we use an expression as a column of output, we cannot use that column directly in the Where condition as a criterion. For example, the following SQL statement:select id (C1 + C2 ) as s from t1 where s > 100 & nbsp SQL Server Error: Select Id (C1 + c2) as s from t1 where (C1 + c2) >
The
is no problem. But when the expression is complex, it is cumbersome. is there a way to use such a column name in the Where? or is there any other way to solve such problems? Workaround:
sql code copy code
-
select t2. *from (select id (C1 + c2) as C from t1 T2 where C > + --or select t2.< span class= "C" >*from (select id, C = C1+c2 from t1 T2where C > 100
because column aliases cannot be used directly in the where statement, we need to wrap the SQL statement in Oracle, referencing column aliases in a WHERE clause can be an error , what is this for? because: The order of execution of the SELECT statement 1. From Statement 2. Where statement (binding condition) 3. Start with statement &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&Nbsp; 4. Connect by Statement 5. Where statement 6. GROUP BY Statement 7. Having statements 8. Model Statement 9. SELECT statement 10. Union, minus, intersect, etc. set calculus calculus &NBSP;&NBSP;&NBSP;&NBSP;&NBSp; 11. ORDER BY statement
Reprint: SQL statements use aliases in where to determine conditions