I am new to Sql server, and my MySql background is only decent, nothing exceptional.
I have a table with 5 columns:
Neighbrhood
City
State
zip_code
zip_percent
The goal of the query: To provide a list of neighborhoods (unique) within a city and the zip_code that corresponds with the highest zip_percent. Thus returning 2 columns:
Neighborhood
zip_code
Where the zip_code is the "most representative" of the neighborhood, by virtue of being of the highest percent coverage or "zip_percent"
Issues: Since a neighborhood can overlap multiple zip_codes I am having an issue getting them distinctly. The distinct clause prevents me from ordering by an unselected column.
Somehow I think I need to take this subquery and join it back onto the original table using a MAX command on the zip_percent column. I just can't quite put all the pieces together. I would really appreciate any help.
You can see an example of the issue here with Neighborhoods like 'Arbor Heights' and 'Rainer Beach'