count distinct values in group by sql