Database: voter_1
# area_code_state ( area_code , state )
# contestants ( contestant_number , contestant_name )
# votes ( vote_id , phone_number , state , contestant_number , created )
# votes.contestant_number = contestants.contestant_number
# votes.state = area_code_state.state

Question: How many states are there?
SQL: select count ( * ) from area_code_state

Question: List the contestant numbers and names, ordered by contestant name descending.
SQL: select contestant_number , contestant_name from contestants order by contestant_name desc

Question: List the vote ids, phone numbers and states of all votes.
SQL: select vote_id , phone_number , state from votes

Question: What are the maximum and minimum values of area codes?
SQL: select max ( area_code ) , min ( area_code ) from area_code_state

Question: What is last date created of votes from the state 'CA'?
SQL: select max ( created ) from votes where state = 'CA'

Question: What are the names of the contestants whose names are not 'Jessie Alloway'
SQL: select contestant_name from contestants where contestant_name != 'Jessie Alloway'

Question: What are the distinct states and create time of all votes?
SQL: select distinct state , created from votes

Question: What are the contestant numbers and names of the contestants who had at least two votes?
SQL: select contestants.contestant_number , contestants.contestant_name from contestants join votes on contestants.contestant_number = votes.contestant_number group by contestants.contestant_number having count ( * ) >= 2

Question: Of all the contestants who got voted, what is the contestant number and name of the contestant who got least votes?
SQL: select contestants.contestant_number , contestants.contestant_name from contestants join votes on contestants.contestant_number = votes.contestant_number group by contestants.contestant_number order by count ( * ) asc limit 1

Question: What are the number of votes from state 'NY' or 'CA'?
SQL: select count ( * ) from votes where state = 'NY' or state = 'CA'

Question: How many contestants did not get voted?
SQL: select count ( * ) from contestants where contestant_number not in ( select contestant_number from votes )

Question: What is the area code in which the most voters voted?
SQL: select area_code_state.area_code from area_code_state join votes on area_code_state.state = votes.state group by area_code_state.area_code order by count ( * ) desc limit 1

Question: What are the create dates, states, and phone numbers of the votes that were for the contestant named 'Tabatha Gehling'?
SQL: select votes.created , votes.state , votes.phone_number from contestants join votes on contestants.contestant_number = votes.contestant_number where contestants.contestant_name = 'Tabatha Gehling'

Question: List the area codes in which voters voted both for the contestant 'Tabatha Gehling' and the contestant 'Kelly Clauss'.
SQL: select area_code_state.area_code from contestants join votes on contestants.contestant_number = votes.contestant_number join area_code_state on votes.state = area_code_state.state where contestants.contestant_name = 'Tabatha Gehling' intersect select area_code_state.area_code from contestants join votes on contestants.contestant_number = votes.contestant_number join area_code_state on votes.state = area_code_state.state where contestants.contestant_name = 'Kelly Clauss'

Question: Return the names of the contestants whose names contain the substring 'Al' .
SQL: select contestant_name from contestants where contestant_name like '%al%'