MySQL count distinct statistic results go heavy

Source: Internet
Author: User

MySQL SQL statement, count this keyword can be in the number of statistics, such as

There is a TableA table with the following data in the table:

Id Name Age
1 Tony 18
2 Jacky 19
3 JoJo 18


SELECT COUNT (age) from TableA

The above statement can find out how many data are in table tables. The query result is 3

While the Count keyword is used together with distinct, you can count the number of fields in the data that are not duplicated. Such as:

SELECT COUNT (DISTINCT age) from TableA

The query result of the above statement is the de-weight of the age field. The result is 2.

MySQL count distinct statistic results go heavy

Related Article

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.