select count distinct group by sql