column_names: -1
*
0
area code
0
state
1
contestant number
1
contestant name
2
vote id
2
phone number
2
state
2
contestant number
2
created
column_names_original: -1
*
0
area_code
0
state
1
contestant_number
1
contestant_name
2
vote_id
2
phone_number
2
state
2
contestant_number
2
created
column_types: text
number
text
number
text
number
number
text
number
time
db_id: voter_1
table_names: area code state
contestants
votes
table_names_original: AREA_CODE_STATE
CONTESTANTS
VOTES

How many states are there?
SELECT count(*) FROM area_code_state

List the contestant numbers and names, ordered by contestant name descending.
SELECT contestant_number ,  contestant_name FROM contestants ORDER BY contestant_name DESC

List the vote ids, phone numbers and states of all votes.
SELECT vote_id ,  phone_number ,  state FROM votes

What are the maximum and minimum values of area codes?
SELECT max(area_code) ,  min(area_code) FROM area_code_state

What is last date created of votes from the state 'CA'?
SELECT max(created) FROM votes WHERE state  =  'CA'

What are the names of the contestants whose names are not 'Jessie Alloway'
SELECT contestant_name FROM contestants WHERE contestant_name != 'Jessie Alloway'

What are the distinct states and create time of all votes?
SELECT DISTINCT state ,  created FROM votes

What are the contestant numbers and names of the contestants who had at least two votes?
SELECT T1.contestant_number , T1.contestant_name FROM contestants AS T1 JOIN votes AS T2 ON T1.contestant_number  =  T2.contestant_number GROUP BY T1.contestant_number HAVING count(*)  >=  2

Of all the contestants who got voted, what is the contestant number and name of the contestant who got least votes?
SELECT T1.contestant_number , T1.contestant_name FROM contestants AS T1 JOIN votes AS T2 ON T1.contestant_number  =  T2.contestant_number GROUP BY T1.contestant_number ORDER BY count(*) ASC LIMIT 1

What are the number of votes from state 'NY' or 'CA'?
SELECT count(*) FROM votes WHERE state  =  'NY' OR state  =  'CA'

How many contestants did not get voted?
SELECT count(*) FROM contestants WHERE contestant_number NOT IN ( SELECT contestant_number FROM votes )

What is the area code in which the most voters voted?
SELECT T1.area_code FROM area_code_state AS T1 JOIN votes AS T2 ON T1.state  =  T2.state GROUP BY T1.area_code ORDER BY count(*) DESC LIMIT 1

What are the create dates, states, and phone numbers of the votes that were for the contestant named 'Tabatha Gehling'?
SELECT T2.created ,  T2.state ,  T2.phone_number FROM contestants AS T1 JOIN votes AS T2 ON T1.contestant_number  =  T2.contestant_number WHERE T1.contestant_name  =  'Tabatha Gehling'

List the area codes in which voters voted both for the contestant 'Tabatha Gehling' and the contestant 'Kelly Clauss'.
SELECT T3.area_code FROM contestants AS T1 JOIN votes AS T2 ON T1.contestant_number  =  T2.contestant_number JOIN area_code_state AS T3 ON T2.state  =  T3.state WHERE T1.contestant_name  =  'Tabatha Gehling' INTERSECT SELECT T3.area_code FROM contestants AS T1 JOIN votes AS T2 ON T1.contestant_number  =  T2.contestant_number JOIN area_code_state AS T3 ON T2.state  =  T3.state WHERE T1.contestant_name  =  'Kelly Clauss'

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