human
Schema:
county (County_Id, County_name, Population, Zip_code)
party (Party_ID, Year, Party, Governor, Lieutenant_Governor, Comptroller, Attorney_General, US_Senate)
election (Election_ID, Counties_Represented, District, Delegate, Party, First_Elected, Committee)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the 3 counties with the smallest population.
assistant
SELECT County_name FROM county ORDER BY Population ASC LIMIT 3
human
Which delegates are from counties with population smaller than 100000?
assistant
SELECT T2.Delegate FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population < 100000
human
How many distinct delegates are from counties with population larger than 50000?
assistant
SELECT count(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T1.Population > 50000
human
Show the name of the county with the biggest population.
assistant
SELECT County_name FROM county ORDER BY Population DESC LIMIT 1
human
How many counties are there in total?
assistant
SELECT count(*) FROM county
human
On average how large is the population of the counties?
assistant
SELECT avg ( Population ) FROM county ;