Sql Query Count Distinct In R Programming