I need to count the distinct number of people who visit each restaurant location. Multiple visits by the same person to the same location should only be counted once.
Input:
location visitor
-------------------
sydney john
melbourne john
melbourne jane
melbourne pete
sydney paul
melbourne jane
sydney jake
sydney john
sydney john
melbourne jake
sydney john
Expected output:
location count
-----------------
sydney 3
melbourne 4
I've tried to follow examples here Using group by on multiple columns, nested SQL queries like this one
select distinct location,count(*) as c from (select distinct location,distinct visitor from guests) group by location,visitor order by c desc
and endless Googling with no luck.