I have 2 tables:
usStateCities:

And usstatescentroids:

SELECT state,COUNT(*) AS count FROM usStateCities GROUP BY state
Gives the number of cities in each state
SELECT *
FROM (SELECT state, COUNT(*) AS count FROM usstatecities ) AS a,
usstatescentroids b
WHERE a.state = b.state
GROUP BY state
Only gives one state and total number of cities in US
I want to find the number of cities in each state and the coordinates (lon,lat) of the centroid of each state.
CORRECTION I have change State to state. I cut and pasted older statements.
1 Answer