SELECT statement structure and execution order

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.