"SQL Server" System learning Three: Logical query processing phase-six-segment

Source: Internet
Author: User

First, from the stage

For connection instructions:

1. Cartesian product

2. On filter

Interrupted: Unknown=not unknuwn missing value;

The filter (on where has) handles unknown as false, excluding the filter results. If you compare two null, the result is not equal, false

As true in a check constraint, such as requiring a column greater than 0, is successful when NULL is inserted, and null>0 is considered to be ture. If you compare two null, the result is equal, and the comparison is considered equal in unique constraints, set operations (such as union, except), sorting, grouping.

3. Add external lines (outer joins)

Second, where

You cannot use an aggregate function because it is not grouped yet, and you cannot use the column alias specified in SELECT.

Third, GROUP by

Four, having

V. Select Stage

1. Aggregation Operations

2, Discount row weight

3. Top

If an order by is not specified, the returned set is indeterminate

When with ties is specified, the last row is checked and all rows with the same value as the last row are returned.

Vi. ORDER BY

This step returns no longer a valid table, but rather a cursor, which is why the change statement cannot be used in a table expression. (Do you remember the table expression?) views, inline table-valued functions, derived tables, CTE

Exception, when used with top, as a logical finite order to get the first n, the rows returned are not ordered, and the order is not guaranteed, which requires attention.

If it is not necessary, do not easily specify an order by, perform an index scan, or execute the sort operator.

Order by considers null to be equal. At the same time, NULL is smaller than the known value and is ranked first.

Extended:

One, table operators

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.