1.步骤序号
1.1 查询的一般形式
SELECT DISTINCT <TOP_specification> <select_list>
FROM <left_table>
<join_type> JOIN <right_table>
ON <join_condition>
WHERE <where_condition>
GROUP BY <group_by_list>
WITH {CUBE | ROLLUP}
HAVING <having_condition>
ORDER BY <order_by_list>
1.2. 根据各个子句被逻辑处理的顺序附以步骤序号
1.3. 查询流程图
查询流程图中,ORDER BY和TOP是处理顺序是反的。"……why TOP operators come earlier than ORDER BY in the query execution plan."
引申
参考资料
- Microsoft SQL Server 2005 技术内幕:T-SQL 查询 - Itzik Ben-Gan & Lubor Kollar & Dejan Sarka