0

I have a table where I have the following columns - lets call location table city, state, zipcode, lat, lng

The problem is that every city and state can multiple zip codes e.g.

belleuve, wa, 98004 bellevue, wa, 98006

Similarly a city name can be also present in some other state e.g.

bellevue, TN, 05156

How do I select a distinct city e.g. Bellevue for each state. Basically the result should show both Bellevue, WA and Bellevue, TN but for WA only one occurance of Bellevue.

1 Answer 1

1

Grouping by the city and state should work here:

SELECT City, State
FROM yourTable
GROUP BY City, State;

We also could use DISTINCT:

SELECT DISTINCT City, State
FROM yourTable;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.