Logical Processing Order of the

SELECT  statement:

The main statement used to retrieve data in T-SQL is the SELECT statement. Following are the main query clauses specified in  the order that you are supposed to type them

(known as “keyed-in order”): 

  1. SELECT 
  2. TOP
  3. DISTINCT
  4. FROM 
  5. JOIN
  6. ON
  7. WHERE 
  8. GROUP BY
  9. WITH CUBE or WITH ROLLUP
  10. HAVING
  11. ORDER BY

 

But as mentioned, the logical query processing order, which is the conceptual  interpretation order, is different. It starts with the FROM clause.

The following steps shows the logical processing order, or binding order, for a SELECT  statement.

 Here is the logical query processing order

of the main query clauses:

Note that the actual physical execution of the statement is determined by the query  processor and the order may vary from this list.

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. GROUP BY
  6. WITH CUBE or WITH ROLLUP
  7. HAVING
  8. SELECT
  9. DISTINCT
  10. ORDER BY
  11. TOP