With the following sql statement I can get all unique values with their counts for a given column:
select column, count(column) as count from table
SELECT first_name, last_name, COUNT(distinct last_name) AS c FROM ttable GROUP BY first_name, last_name HAVING c > 999 ORDER BY c DESC
Adding distinct will do it in MYSQL. Thanks