I have a simple table:
Neighbourhood
code neighbourhood country
Some countries have the same neighborhood name. All I want is the total minus the distinct. but I have a problem with the operator; Here is what I am doing.
select count(*)- select distinct(neighbourhood) from Neighbourhood
Advertisement
Answer
So you want:
select count(*) - count(distinct neighbourhood) from Neighbourhood;
I might suggest a further breakdown:
select cnt, count(*), min(neighbourhood), max(neighbourhood) from (select neighbourhood, count(*) as cnt from neighbourhood group by neighbourhood ) n group by cnt order by cnt;
This shows the frequency of duplication along with example value of neighbourhood
.