Posts Tagged ‘mySQL’

mySQL: find out distinct values of a column and the number of their occurrences

So, we need to find out different values of a column and the number of their occurrences. Let’s set up a small test first:

– Step #1: prepare the ground
CREATE DATABASE IF NOT EXISTS `test`;

DROP TABLE IF EXISTS `test`.`test_count_distinct`;

CREATE TABLE `test`.`test_count_distinct` (
`id` INT(11) NOT NULL auto_increment
PRIMARY KEY,
[...]