Database: election

Question: How many counties are there in total?
SQL: SELECT count(*) FROM county

Question: Show the county name and population of all counties.
SQL: SELECT County_name ,  Population FROM county

Question: Show the average population of all counties.
SQL: SELECT avg(Population) FROM county

Question: Return the maximum and minimum population among all counties.
SQL: SELECT max(Population) ,  min(Population) FROM county

Question: Show all the distinct districts for elections.
SQL: SELECT DISTINCT District FROM election

Question: Show the zip code of the county with name "Howard".
SQL: SELECT Zip_code FROM county WHERE County_name  =  "Howard"

Question: Show the delegate from district 1 in election.
SQL: SELECT Delegate FROM election WHERE District  =  1

Question: Show the delegate and committee information of elections.
SQL: SELECT Delegate ,  Committee FROM election

Question: How many distinct governors are there?
SQL: SELECT count(DISTINCT Governor) FROM party

Question: Show the lieutenant governor and comptroller from the democratic party.
SQL: SELECT Lieutenant_Governor ,  Comptroller FROM party WHERE Party  =  "Democratic"

Question: In which distinct years was the governor "Eliot Spitzer"?
SQL: SELECT DISTINCT YEAR FROM party WHERE Governor  =  "Eliot Spitzer"

Question: Show all the information about election.
SQL: SELECT * FROM election

Question: Show the delegates and the names of county they belong to.
SQL: SELECT T2.Delegate ,  T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id  =  T2.District

Question: Which delegates are from counties with population smaller than 100000?
SQL: SELECT T2.Delegate FROM county AS T1 JOIN election AS T2 ON T1.County_id  =  T2.District WHERE T1.Population  <  100000

Question: How many distinct delegates are from counties with population larger than 50000?
SQL: SELECT count(DISTINCT T2.Delegate) FROM county AS T1 JOIN election AS T2 ON T1.County_id  =  T2.District WHERE T1.Population  >  50000

Question: What are the names of the county that the delegates on "Appropriations" committee belong to?
SQL: SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id  =  T2.District WHERE T2.Committee  =  "Appropriations"

Question: Show the delegates and the names of the party they belong to.
SQL: SELECT T1.Delegate ,  T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party  =  T2.Party_ID

Question: Who were the governors of the parties associated with delegates from district 1?
SQL: SELECT T2.Governor FROM election AS T1 JOIN party AS T2 ON T1.Party  =  T2.Party_ID WHERE T1.District  =  1

Question: Who were the comptrollers of the parties associated with the delegates from district 1 or district 2?
SQL: SELECT T2.Comptroller FROM election AS T1 JOIN party AS T2 ON T1.Party  =  T2.Party_ID WHERE T1.District  =  1 OR T1.District  =  2

Question: Return all the committees that have delegates from Democratic party.
SQL: SELECT T1.Committee FROM election AS T1 JOIN party AS T2 ON T1.Party  =  T2.Party_ID WHERE T2.Party  =  "Democratic"