Sql Query Count Distinct In R