当咱们使用某个表达式做为输出的一列时,咱们没法再Where条件中直接使用该列做判断条件.
例以下面的SQL语句:
select t2.*
from (select id, (c1 + c2) as c from t1) t2
where c > 100
--或者
select t2.*
from (select id, c = c1+c2 from t1) t2
where c > 100
因为在Where语句不能直接使用列别名,所以咱们须要将Sql语句给包装一下
在ORACLE中,在WHERE子句中引用列别名会出错,这是为何呢?
由于:SELECT 语句的执行顺序
1. from语句
2. where语句(结合条件)
3. start with语句
4. connect by语句
5. where语句
6. group by语句
7. having语句
8. model语句
9. select语句
10. union、minus、intersect等集合演算演算
11. order by语句this