The structure and execution order of the SELECT statement, and the following ordinal represents the order of execution
8 SELECT (9) DISTINCT
<TOP_specification> <select_list>
1 ROM <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 Ten ORDER by <order_by_list>
Supplemental Note: 1, the above sequence structure is understood as each step to produce a virtual table, which is used as the next step of the input. Only the tables that were generated in the last step are returned to the caller.
2. If the FROM clause contains more than two tables, repeat steps 1 through 3 for the resulting table and the next table for the last join until all the tables are processed.
3. In a query with a GROUP BY clause, the field specified by the Select column is either a field in the GROUP BY clause or included in an aggregate function
(That is, in a query with a GROUP BY clause, as long as the field appearing in the clause of the select must appear in the GROUP BY clause, unless it is an aggregate function)
4, the HAVING clause function is placed after the GROUP BY clause and its combination use, for further filtering
5, distinct is in the have process to do further processing