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 names of counties that have at least two delegates.
assistant
SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District GROUP BY T1.County_id HAVING COUNT(*) >= 2
human
Return the names of all counties sorted by county name in descending alphabetical order.
assistant
SELECT County_name FROM county ORDER BY County_name DESC
human
Show the county name and population of all counties.
assistant
SELECT County_name , Population FROM county
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
What is the zip code the county named 'Howard' is located in?
assistant
SELECT Zip_code FROM county WHERE County_name = "Howard" ;