Statistical data sql statement
SELECT name,count(*) FROM `test` GROUP BY name;
Sort after statistics
SELECT name,count(*) as count FROM `test` GROUP BY name ORDER BY -name;
SELECT name,count(*) as count FROM `test` GROUP BY name HAVING count>2
having
¶The HAVING clause is usually used together with the GROUP BY clause to filter groups according to specified conditions. If the GROUP BY clause is omitted, the behavior of the HAVING clause is similar to that of the WHERE clause.