SQLTeam.com | Weblogs | Forums

Simple question with a complicated answer?

Apologies for the separate post!

I have a data set for landlords (host) and neighbourhoods.

I am stumped by this relatively straight forward question:

Identify if any landlords manage properties in more than 1 neighbourhood.

Pretending this was an SQL Table, I have tried to make a query which I think is far more complicated than it needs to be and wouldn't work if tried using it:

SELECT Host_ID, COUNT(*) from Table GROUP BY Host_ID HAVING COUNT(*) >= 2 AND Neighbourhood = ‘Brooklyn’ OR ‘Manhattan’ OR ‘Queens’ OR ‘Bronx’ OR ‘Staten Island’

If anyone has an SQL query they think might work I would be extremely appreciative!! Thank you :slight_smile:


SELECT Host_ID, COUNT(DISTINCT Neighbourhood) AS Distinct_Neighbourhood_Count
from Table 
GROUP BY Host_ID 
HAVING COUNT(DISTINCT Neighbourhood) > 1

Also host_id might have no meaning to someone that consumes the report, maybe you might want to join it to the source table of host_id and show the real name of Host? Maybe