human
Schema:
county_public_safety (County_ID, Name, Population, Police_officers, Residents_per_officer, Case_burden, Crime_rate, Police_force, Location)
city (City_ID, County_ID, Name, White, Black, Amerindian, Asian, Multiracial, Hispanic)
Please answer with SQL.
assistant
Sure, I understand.
human
List the names of the city with the top 5 white percentages.
assistant
SELECT Name FROM city ORDER BY White DESC LIMIT 5
human
Show the names of cities in counties that have a crime rate less than 100.
assistant
SELECT name FROM city WHERE county_id IN (SELECT county_id FROM county_public_safety WHERE Crime_rate < 100)
human
Show the crime rates of counties in ascending order of number of police officers.
assistant
SELECT Crime_rate FROM county_public_safety ORDER BY Police_officers ASC
human
Please show the police forces and the number of counties with each police force.
assistant
SELECT Police_force , COUNT(*) FROM county_public_safety GROUP BY Police_force
human
List the distinct police forces of counties whose location is not on east side.
assistant
SELECT DISTINCT Police_force FROM county_public_safety WHERE LOCATION != 'East'
human
What are the names of cities that are in the county with the most police officers?
assistant
SELECT name FROM city WHERE county_ID = ( SELECT county_ID FROM county_public_safety ORDER BY Police_officers DESC LIMIT 1 ) ;