当前位置: 代码迷 >> SQL >> (转)SQL话语中,为什么where子句不能使用列别名,而order by却可以
  详细解决方案

(转)SQL话语中,为什么where子句不能使用列别名,而order by却可以

热度:76   发布时间:2016-05-05 13:38:43.0
(转)SQL语句中,为什么where子句不能使用列别名,而order by却可以
sqlserver查询的执行顺序是:
(1)FROM <left_table> <join_type> JOIN <right_table> ON <on_predicate> 
(2)WHERE <where_predicate>
(3)GROUP BY <group_by_specification>
(4)HAVING <having_predicate>
(5)SELECT DISTINCT TOP(<top_specification>) <select_list>   
(6)ORDER BY <order_by_list>               

所以在where执行的时候,别名还不存在,而order by的时候已经存在
  相关解决方案