Introduction to the Logical query processing phase
- from: performs a cartesian product (Cartesian product) (cross join) on the first two tables in the FROM clause, generating a virtual table VT1
- on: The applies an on filter to the VT1. Only those lines that make <join_condition> true are inserted into the VT2.
- OUTER (join): If you specify a OUTER join (relative to a cross join or (INNER join), keep the table (preserved Table: Left outer join marks the left table as a reserved table, right outer join marks the right table as a reserved table, a full outer join marks two tables as a reserved table) and no matching rows are found in the VT2 as an outer row. Generate VT3. If the FROM clause contains more than two tables, repeat steps 1 through 3 for the result table and the next table that you generated for the previous join until you have finished processing all the tables.
- Where: applies a where filter to VT3. Only rows that make <where_condition> true are inserted VT4.
- GROUP By: generates VT5 by grouping rows in VT4 by the list of columns in the GROUP BY clause.
- cube| ROLLUP: Inserts a Hyper-group (suppergroups) into VT5, generating VT6.
- has: has a having filter applied to VT6. Only groups that make
- Select: processes the select list, producing VT8.
- DISTINCT: removes duplicate rows from VT8, resulting in VT9.
- ORDER BY: generates a cursor (VC10) by sorting the rows in VT9 by the list of columns in the ORDER by clause.
- TOP: selects the specified number or scale of rows from the beginning of the VC10, generates the table VT11, and returns the caller.
Note: Step 10, this step is the first step and the only step that can be used to use column aliases in the select list.
Reference: http://tech.ddvip.com/2009-04/1239449159114603.html
Various stages in SQL Server query processing (SQL execution order)