To count distinct values inside of a GROUP BY, use the following.
SELECT col, COUNT(DISTINCT other_col) FROM tab GROUP BY col
The same result can be achieved without using the DISTINCT keyword, as below.
SELECT col, COUNT(*) FROM
(SELECT col, other_col FROM tab GROUP BY col, other_col) t
GROUP BY col