Select COUNT (1) from table where: The function of this SQL statement

Source: Internet
Author: User
The function is to calculate how many rows match a condition.
1 does not represent the first field, but rather represents a fixed value, count (1) and COUNT (2) effect are the same
Count (*), the execution of the asterisk will be translated into the specific name of the field, the effect is the same, but more than a translation of the action, a fixed value is a little less efficient way.
Count (field value) will return a non-empty quantity that meets the criteria

1. Query all data, List 7 columns of data



2. Using the Count (1) query result, return 7




3. Using the Count (*) query result, return 7




4. Parentheses are the field values in the table, count (field values), return the number of data under the C_ID field in the table that is not empty


Returns the number of non-empty data that meets the criteria under the C_ID field



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.