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
- 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