The number of times that all values in the same column are queried in SQL

Source: Internet
Author: User

respect for the original: http://blog.csdn.net/love_java_cc/article/details/52234889

There are tables as follows Table3:

Need to query the number of occurrences in each country in country

SQL statements:

[SQL]View PlainCopy
    1. SELECT country as countries,count (*) as many times from table3 GROUP by country


The results are as follows:

Knowledge Points:

COUNT (*) counts the total number of bars in the result set, and the Count (field name) counts the total number of columns for which the field value is not NULL

GROUP BY: The literal understanding is that the data is grouped according to the rules specified by the by, so that the so-called grouping is dividing a "dataset" into several "small regions" and then data processing for a number of "small regions"

Summary: Count (*) First gets a result set that calculates the total number of values for each field, and then group by is grouped by a field, such as the example above, grouped by country, then count the number of occurrences in each country.

The number of times that all values in the same column are queried in SQL

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.