Distinct Data deduplication Keywords

Source: Internet
Author: User

In the table, duplicate values may be included. That's not a problem, but sometimes you might want to just list different values (distinct). Keyword DISTINCT is used to return only different values.

Table A:

Example 1
Select distinct name from A

The following results are performed:

Example 2
Select DISTINCT name, ID from A

The following results are performed:

is actually based on "Name+id".

Example 3: Statistics
Select COUNT (distinct name) from A;  --The number of the table name to go back to, SQL Server support, and Access does not support select COUNT (distinct name, id) from A;  --sql server and access do not support
Example 4
Select ID, distinct name from A;   --The error will be indicated because the distinct must be placed at the beginning
Other

The field selected in the distinct statement can only be a field specified by distinct, and other fields are not possible. For example, if Table A has a memo column, if you want to get Distinc name and the corresponding Memo field, it is not possible to go directly through distinct.
However, there are other ways to implement a discussion of how SQL Server will stitch up multiple lines of content into one row

Distinct Data deduplication Keywords

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.