Saturday, October 09, 2010

Processing order of SELECT Statement

 

The following steps show the processing order for a SELECT statement.

  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


This is the reason where we can not use column alias on Where clause, however we can use it on Select / Order by.

If interested on the logical order of the query processing poster, download it from here.

Reference: http://msdn.microsoft.com/en-us/library/ms189499.aspx

No comments: