count and group by in mysql code example
Example: mysql count grouped rows
SELECT DISTINCT my_field, COUNT(*) FROM my_table GROUP BY my_field;
-- Count of grouped rows:
SELECT COUNT(*) FROM (
SELECT DISTINCT my_field FROM my_table
);
SELECT DISTINCT my_field, COUNT(*) FROM my_table GROUP BY my_field;
-- Count of grouped rows:
SELECT COUNT(*) FROM (
SELECT DISTINCT my_field FROM my_table
);