MySQL COUNT, group by, and mysqlcount
Group by is used to group the results, which facilitates statistics After grouping, so there will always be count followed
See the following table for example:
Group by ID, count the number of times each ID is repeated
SELECT yww_test.id, COUNT (id) as nFROM yww_testGROUP BY yww_test.id
Record duplication can be found as follows:
SELECT id, COUNT (*) AS nFROM yww_testGROUP BY yww_test.idHAVING COUNT (*)> 1;
Count (*) is used to count the number of rows in each group.
Note:
Count (*) returns the total number of all existing rows in the table, including rows with null values. However, count (column name) returns the total number of all rows except null in the table (columns with default values are also included ).
Distinct column name. The result is the result after the value is null and the duplicate data is deleted.
Reference: http://www.111cn.net/database/mysql/53202.htm
For more group by, see: http://blog.csdn.net/xxpyeippx/article/details/8059910