Group BY is used to group the results, which is easy to count after grouping, so there will always be count followed by
For example, the following table:
Group by ID, count each ID repeated several times
SELECT Yww_test.id,count (ID) as Nfrom yww_testgroup by yww_test.id
To find out the duplicate records can be like this.
SELECT Id,count (*) as Nfrom Yww_testgroup by Yww_test.idhaving COUNT (*) >1;
where COUNT (*) is the count of how many rows each group has
Attention:
COUNT (*) returns the total number of rows that exist in the table, including rows with a value of NULL, whereas count (column name) returns the total number of all rows except null in the table (columns with default values will also be counted).
Distinct the column name, the result will be the result of dropping the value null and repeating the data
Reference: http://www.111cn.net/database/mysql/53202.htm
For more Group by please refer to: http://blog.csdn.net/xxpyeippx/article/details/8059910
MySQL COUNT and GROUP by