Unlike normal program code, SQL executes in a certain order, and his first execution is always executed from the From, although select appears in the first position but the execution order is not the first one. Sometimes you may write a long code, not necessarily a good understanding of the SQL execution order. I can not understand it very well, so today I will tidy up the SQL execution order. Reference Example: @qanholas
Each step produces a virtual table that is used as input to the next step. These virtual tables are not available to callers (client applications or external queries). Only the table generated in the last step is returned to the caller. If you do not specify a clause in the query, the corresponding step is skipped.
(8)SELECT(9)DISTINCT( One)<TopNum> <SelectList>(1) from [left_table](3)<Join_type> JOIN <Right_table>(2) on <Join_condition>(4)WHERE <Where_condition>(5)GROUP by <Group_by_list>(6) with <CUBE|RollUP>(7) having <Having_condition>(Ten)ORDER by <Order_by_list>
In fact, I feel better in this example, so I borrowed it directly. So let's just get a quick look at his execution sequence process.
This is just my personal understanding. What's wrong with the hope of advice thank you.
Reference: http://www.cnblogs.com/qanholas/archive/2010/10/24/1859924.html
Initial knowledge of SQL execution order