Table: election_results_22
Columns: district
incumbent
party
first_elected
result
candidates

Question: how many times was the incumbent is john b. yates?
SQL: SELECT COUNT("party") FROM election_results_22 WHERE "incumbent" = 'John B. Yates'

Question: when was the first elected when the  candidates is thomas lawyer (dr) 54.9% william beekman (f) 45.1%?
SQL: SELECT "first_elected" FROM election_results_22 WHERE "candidates" = 'Thomas Lawyer (DR) 54.9% William Beekman (F) 45.1%'

Question: who are the candidates for district new york 10?
SQL: SELECT "candidates" FROM election_results_22 WHERE "district" = 'New York 10'

Question: how many times were the candidates thomas h. hubbard (dr) 51.5% simeon ford (f) 48.4%?
SQL: SELECT COUNT("party") FROM election_results_22 WHERE "candidates" = 'Thomas H. Hubbard (DR) 51.5% Simeon Ford (F) 48.4%'

Question: what is the district when the party is federalist and first elected is 1814?
SQL: SELECT "district" FROM election_results_22 WHERE "party" = 'Federalist' AND "first_elected" = '1814'