Skip to main content

MySQL query to count unique values of one column.

-- Count unique values of one column

SELECT
  col_name,
  COUNT(*) AS frequency
FROM
  tbl_name
GROUP BY
  col_name
ORDER BY
  frequency DESC;