SQL Server SELECT statement Summary (1)

Source: Internet
Author: User
SQL Server learning-Summary of SELECT statements (1) logical order of query processing (return result list (01) FROM Table (] basic component of SELECT statement Setp1: the table name can be specified in the [FROM] from clause. In this step, SQLServer lists the tables used by the select statement. If the join table is specified, it is listed together.

SQL Server learning-Summary of SELECT statements (1) logical order of query processing (return result list (01) FROM table ()] basic component of SELECT statement Setp1: the table name can be specified in the [FROM] from clause. In this step, SQL Server lists the tables used by the select statement. If the join table is specified, the tables are listed together.

SQL Server learning-Summary of SELECT statements (1)

Logical order of Query Processing

(Return result list (01) FROM Table (]

Basic Components of SELECT statements

Setp1: [FROM]

The table name can be specified in the from clause. In this step, SQL Server will list the tables used by the select statement. If the join table is specified, the tables will be listed together. By means of staggered arrangement, put possible combinations in VT1 (in the first virtual table ).

Setp2: [ON]

Compare the data in VT1 and insert the correct data into VT2 when the condition is set.

Setp3: [Outer (join)]

If outer join is defined instead of cross join or inner join, no corresponding record in the VT2 table is saved as an external record.

The formation of VT3. If the number of tables in the from clause exceeds two, setp1 ~ 3. The join execution result and the next table marked by the from clause

Execute each other until all the tables are processed.

Setp4: [WHERE filter condition]

Filter data in VT3 to form a qualified column in VT4.

Setp5: [Group by]

The group by clause can be used to specify the VT4 grouping mode, and the execution result is VT5.

Setp6: [CUBE | ROLLUP]

Cube | The rollup clause performs further group by operations on group by data in setp5. If setp5 is compared to the subtotal of data

Value, server space, so setp6 is the total value of the calculated data, and the generated data will be inserted into VT6.

Setp7: [HAVING]

Determine whether the fields in the grouping table completed by VT6 meet the having setting conditions. When this condition is met, it is inserted into VT7.

Setp8: [SELECT]

Use select to generate the returned results. select only the fields that meet the requirements to generate VT8.

Setp9: [DISTINCT]

Remove the duplicate data record of VT8, the Hong Kong server, and insert the result into VT9.

Setp10: [Order by order_list [ASC | DESC]

Specify the sort method (ascending or descending) of VT9, and form the sorted result into VT10.

Setp11: [TOP]

When this keyword is used, on the Hong Kong SERVER, SQL SERVER inserts the first n data entries in VT10 into VT11 and returns them to the user.

Setp12: [return result list]

Return items (such as columns, expressions, variables, or constants that describe the result set), and separate the list with commas.

Setp13: [INTO new table name]

The independent variables that can be omitted are used to create a new table using the project and Data Type Structure in the "return result list ".

Table name.

Posted on

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.