aherntech/sparc huggingface dataset:
Database: customers_and_products_contacts
Question sequence:
Show the date from and date to for each customer address history.
For each of those records, also show the customer name.
For each of those, also show the customer address city.
SQL query sequence:
SELECT date_from , date_to FROM customer_address_history
SELECT T2.customer_name ,  T1.date_from ,  T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.customer_id
SELECT T2.customer_name ,  T3.city ,  T1.date_from ,  T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.customer_id JOIN addresses AS T3 ON T1.address_id  =  T3.address_id
Final question: Show the customer name, customer address city, date from, and date to for each customer address history.
Final SQL: SELECT T2.customer_name ,  T3.city ,  T1.date_from ,  T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id  =  T2.customer_id JOIN addresses AS T3 ON T1.address_id  =  T3.address_id
Database: customers_and_products_contacts
Question sequence:
Show the names of all customers.
Count the number of orders each of them has made.
For each of them, how many of their orders use Credit Card payment method?
Show the names of those who have more than 2 such orders.
SQL query sequence:
SELECT customer_name FROM customers
SELECT T1.customer_name, count(*) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id
SELECT T1.customer_name, count(*) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T1.payment_method_code  =  'Credit Card' GROUP BY T1.customer_id
SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T1.payment_method_code  =  'Credit Card' GROUP BY T1.customer_id HAVING count(*)  >  2
Final question: Show the names of customers who use Credit Card payment method and have more than 2 orders.
Final SQL: SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id WHERE T1.payment_method_code  =  'Credit Card' GROUP BY T1.customer_id HAVING count(*)  >  2
Database: customers_and_products_contacts
Question sequence:
Show the names of all customers.
Also show their phone numbers.
For each of them, what is the total product quantity of their orders?
Sort the results in descending order of the quantity.
What are the name and phone number of the customer with the most?
SQL query sequence:
select customer_name from customers
select customer_name, customer_phone from customers
SELECT  T1.customer_name ,  T1.customer_phone,  sum(T3.order_quantity) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T3.order_id  =  T2.order_id GROUP BY T1.customer_id
SELECT  T1.customer_name ,  T1.customer_phone,  sum(T3.order_quantity) FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T3.order_id  =  T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC
SELECT  T1.customer_name ,  T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T3.order_id  =  T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1
Final question: What are the name and phone of the customer with the most ordered product quantity?
Final SQL: SELECT  T1.customer_name ,  T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id JOIN order_items AS T3 ON T3.order_id  =  T2.order_id GROUP BY T1.customer_id ORDER BY sum(T3.order_quantity) DESC LIMIT 1
Database: student_1
Question sequence:
Show me the last names of all teachers.
Show me the student grade in each classroom.
Which classrooms do fifth grade students have?
Show me the teachers who teach in any of those classrooms.
SQL query sequence:
SELECT lastname FROM teachers
SELECT distinct classroom,grade FROM list
SELECT distinct classroom FROM list WHERE Grade = 5
SELECT DISTINCT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE grade  =  5
Final question: Find the last names of the teachers that teach fifth grade.
Final SQL: SELECT DISTINCT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE grade  =  5
Database: student_1
Question sequence:
Show me the first names of all teachers.
Show me the student grade in each classroom.
Which classrooms do first grade students have?
Show me the teachers who teach in any of those classrooms.
SQL query sequence:
SELECT firstname FROM teachers
SELECT distinct classroom,grade FROM list
SELECT distinct classroom FROM list WHERE Grade = 1
SELECT DISTINCT T2.firstname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE grade  =  1
Final question: Find the first names of the teachers that teach first grade.
Final SQL: SELECT DISTINCT T2.firstname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE grade  =  1
Database: student_1
Question sequence:
Show me the name of all teachers in record.
Which classrooms does OTHA MOYER teach in?
Show me the name of students who are in those classrooms.
SQL query sequence:
SELECT firstname, lastname FROM teachers
SELECT classroom FROM teachers where firstname  =  "OTHA" AND lastname  =  "MOYER"
SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "OTHA" AND T2.lastname  =  "MOYER"
Final question: Find all students taught by OTHA MOYER. Output the first and last names of the students.
Final SQL: SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "OTHA" AND T2.lastname  =  "MOYER"
Database: student_1
Question sequence:
Show me the name of all teachers in record.
Which classrooms does MARROTTE KIRK teach in?
Show me the name of students who are in those classrooms.
SQL query sequence:
SELECT firstname, lastname FROM teachers
SELECT classroom FROM teachers where firstname  =  "MARROTTE" AND lastname  =  "KIRK"
SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "MARROTTE" AND T2.lastname  =  "KIRK"
Final question: Find all students taught by MARROTTE KIRK. Output first and last names of students.
Final SQL: SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "MARROTTE" AND T2.lastname  =  "KIRK"
Database: student_1
Question sequence:
How many students are there in the file?
Give me the classroom EVELINA BROMLEY is in.
Show me the name of teachers that teach in that classroom.
SQL query sequence:
SELECT COUNT(*) FROM list
SELECT Classroom FROM list WHERE firstname  =  "EVELINA" AND lastname  =  "BROMLEY"
SELECT T2.firstname ,  T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "EVELINA" AND T1.lastname  =  "BROMLEY"
Final question: Find the first and last name of all the teachers that teach EVELINA BROMLEY.
Final SQL: SELECT T2.firstname ,  T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "EVELINA" AND T1.lastname  =  "BROMLEY"
Database: student_1
Question sequence:
How many students are there in the file?
Give me the classroom GELL TAMI is in.
Show me the last name of teachers that teach in that classroom.
SQL query sequence:
SELECT COUNT(*) FROM list
SELECT Classroom FROM list WHERE firstname  =  "EVELINA" AND lastname  =  "BROMLEY"
SELECT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "GELL" AND T1.lastname  =  "TAMI"
Final question: Find the last names of all the teachers that teach GELL TAMI.
Final SQL: SELECT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "GELL" AND T1.lastname  =  "TAMI"
Database: student_1
Question sequence:
Show me the name of all teachers in record.
Which classrooms does LORIA ONDERSMA teach in?
How many students study in those classrooms?
SQL query sequence:
SELECT firstname, lastname FROM teachers
SELECT classroom FROM teachers WHERE firstname  =  "LORIA" AND lastname  =  "ONDERSMA"
SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "LORIA" AND T2.lastname  =  "ONDERSMA"
Final question: How many students does LORIA ONDERSMA teaches?
Final SQL: SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "LORIA" AND T2.lastname  =  "ONDERSMA"
Database: student_1
Question sequence:
Show me the name of all teachers in record.
Which classrooms does KAWA GORDON teach in?
How many students study in those classrooms?
SQL query sequence:
SELECT firstname, lastname FROM teachers
SELECT classroom FROM teachers WHERE firstname  =  "KAWA" AND lastname  =  "GORDON"
SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "KAWA" AND T2.lastname  =  "GORDON"
Final question: How many students does KAWA GORDON teaches?
Final SQL: SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "KAWA" AND T2.lastname  =  "GORDON"
Database: student_1
Question sequence:
Show me the name of all teachers in record.
Which classrooms does TARRING LEIA teach in?
How many students study in those classrooms?
SQL query sequence:
SELECT firstname, lastname FROM teachers
SELECT classroom FROM teachers WHERE firstname  =  "TARRING" AND lastname  =  "LEIA"
SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "TARRING" AND T2.lastname  =  "LEIA"
Final question: Find the number of students taught by TARRING LEIA.
Final SQL: SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "TARRING" AND T2.lastname  =  "LEIA"
Database: student_1
Question sequence:
How many teachers are there in record?
What classrooms is CHRISSY NABOZNY in?
How many are they?
SQL query sequence:
SELECT count(*) FROM teachers
SELECT classroom FROM list WHERE firstname  =  "CHRISSY" AND lastname  =  "NABOZNY"
SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "CHRISSY" AND T1.lastname  =  "NABOZNY"
Final question: How many teachers does the student named CHRISSY NABOZNY have?
Final SQL: SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "CHRISSY" AND T1.lastname  =  "NABOZNY"
Database: student_1
Question sequence:
How many teachers are there in record?
What classrooms is MADLOCK RAY in?
How many are they?
SQL query sequence:
SELECT count(*) FROM teachers
SELECT classroom FROM list WHERE firstname  =  "CHRISSY" AND lastname  =  "NABOZNY"
SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "MADLOCK" AND T1.lastname  =  "RAY"
Final question: How many teachers does the student named MADLOCK RAY have?
Final SQL: SELECT count(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.firstname  =  "MADLOCK" AND T1.lastname  =  "RAY"
Database: student_1
Question sequence:
How many teachers are there?
Show me the classroom of OTHA MOYER.
What about classrooms other than that?
Give me the name of all first-grade students who are in any of those classrooms.
SQL query sequence:
SELECT COUNT(*) FROM teachers
SELECT classroom FROM teachers WHERE firstname  =  "OTHA" AND lastname  =  "MOYER"
SELECT distinct classroom FROM list WHERE classroom not in SELECT classroom FROM teachers WHERE firstname  =  "OTHA" AND lastname  =  "MOYER"
SELECT DISTINCT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.grade  =  1 EXCEPT SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "OTHA" AND T2.lastname  =  "MOYER"
Final question: Find all first-grade students who are NOT taught by OTHA MOYER. Report their first and last names.
Final SQL: SELECT DISTINCT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.grade  =  1 EXCEPT SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "OTHA" AND T2.lastname  =  "MOYER"
Database: student_1
Question sequence:
How many teachers are there?
Show me the classroom of OTHA MOYER.
What about classrooms other than that?
Give me the name of all first-grade students who are in any of those classrooms.
SQL query sequence:
SELECT COUNT(*) FROM teachers
SELECT classroom FROM teachers WHERE firstname  =  "OTHA" AND lastname  =  "MOYER"
SELECT distinct classroom FROM list WHERE classroom not in SELECT classroom FROM teachers WHERE firstname  =  "OTHA" AND lastname  =  "MOYER"
SELECT DISTINCT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.grade  =  1 EXCEPT SELECT T1.firstname ,  T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T2.firstname  =  "OTHA" AND T2.lastname  =  "MOYER"
Final question: Find the last names of the students in third grade that are not taught by COVIN JEROME.
Final SQL: SELECT DISTINCT T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom  =  T2.classroom WHERE T1.grade  =  3 AND T2.firstname != "COVIN" AND T2.lastname != "JEROME"
Database: student_1
Question sequence:
How many students are there in record?
What about that in terms of each grade?
Also include number of classrooms.
SQL query sequence:
SELECT count(*) FROM list
SELECT grade, count(*) FROM list GROUP BY grade
SELECT grade ,  count(DISTINCT classroom) ,  count(*) FROM list GROUP BY grade
Final question: For each grade, report the grade, the number of classrooms in which it is taught and the total number of students in the grade.
Final SQL: SELECT grade ,  count(DISTINCT classroom) ,  count(*) FROM list GROUP BY grade
Database: student_1
Question sequence:
How many classrooms are there?
How many students does each of them have?
Give me the classroom with the most of them.
SQL query sequence:
SELECT DISTINCT classroom FROM list
SELECT classroom, count(*) FROM list GROUP BY classroom
SELECT classroom FROM list GROUP BY classroom ORDER BY count(*) DESC LIMIT 1
Final question: Which classroom has the most students?
Final SQL: SELECT classroom FROM list GROUP BY classroom ORDER BY count(*) DESC LIMIT 1
Database: student_1
Question sequence:
How many classrooms are there?
Show me the classrooms that any zero grade is in.
How many students are in each of those classrooms?
SQL query sequence:
SELECT DISTINCT classroom FROM list
SELECT distinct classroom FROM list WHERE grade = '0'
SELECT classroom ,  count(*) FROM list WHERE grade  =  "0" GROUP BY classroom
Final question: For each grade 0 classroom, report the total number of students.
Final SQL: SELECT classroom ,  count(*) FROM list WHERE grade  =  "0" GROUP BY classroom
Database: student_1
Question sequence:
How many classrooms are there?
Show me the classrooms that any fourth-grade is in.
How many students are in each of those classrooms?
SQL query sequence:
SELECT DISTINCT classroom FROM list
SELECT distinct classroom FROM list WHERE grade = '4'
SELECT classroom ,  count(*) FROM list WHERE grade  =  "4" GROUP BY classroom
Final question: Report the total number of students for each fourth-grade classroom.
Final SQL: SELECT classroom ,  count(*) FROM list WHERE grade  =  "4" GROUP BY classroom
Database: voter_2
Question sequence:
How many students have major 600?
What is the maximum age of these students?
Please show the minimum age as well.
SQL query sequence:
SELECT count(*) FROM STUDENT WHERE Major  =  600
SELECT max(Age) FROM STUDENT WHERE Major  =  600
SELECT max(Age) ,  min(Age) FROM STUDENT WHERE Major  =  600
Final question: What are the maximum and minimum age of students with major 600?
Final SQL: SELECT max(Age) ,  min(Age) FROM STUDENT WHERE Major  =  600
Database: voter_2
Question sequence:
How many students have secretary votes?
How many of those are from the fall election cycle?
What are the names of those students?
What are their ages?
SQL query sequence:
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Secretary_Vote
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Secretary_Vote WHERE T2.Election_Cycle  =  "Fall"
SELECT DISTINCT T1.Fname, T1.Lname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Secretary_Vote WHERE T2.Election_Cycle  =  "Fall"
SELECT DISTINCT T1.Age FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Secretary_Vote WHERE T2.Election_Cycle  =  "Fall"
Final question: Find the distinct ages of students who have secretary votes in the fall election cycle.
Final SQL: SELECT DISTINCT T1.Age FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Secretary_Vote WHERE T2.Election_Cycle  =  "Fall"
Database: voter_2
Question sequence:
How many students have treasurer votes?
How many of those are from the spring election cycle?
Please list their names.
Who are their advisors?
SQL query sequence:
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Treasurer_Vote
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Treasurer_Vote WHERE T2.Election_Cycle  =  "Spring"
SELECT DISTINCT T1.Fname, T1.Lname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Treasurer_Vote WHERE T2.Election_Cycle  =  "Spring"
SELECT DISTINCT T1.Advisor FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Treasurer_Vote WHERE T2.Election_Cycle  =  "Spring"
Final question: Find the distinct Advisor of students who have treasurer votes in the spring election cycle.
Final SQL: SELECT DISTINCT T1.Advisor FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Treasurer_Vote WHERE T2.Election_Cycle  =  "Spring"
Database: voter_2
Question sequence:
How many students have president votes?
How many of them are female?
What are their first and last names?
SQL query sequence:
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.President_Vote
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.President_Vote WHERE T1.sex  =  "F"
SELECT DISTINCT T1.Fname ,  T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.President_VOTE WHERE T1.sex  =  "F"
Final question: Find the first and last names of all the female (sex is F) students who have president votes.
Final SQL: SELECT DISTINCT T1.Fname ,  T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.President_VOTE WHERE T1.sex  =  "F"
Database: voter_2
Question sequence:
How many students have vice President votes?
What are their names?
How many of them are 18 years old?
What are their first and last names?
SQL query sequence:
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Vice_President_Vote
SELECT DISTINCT T1.Fname, T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Vice_President_Vote
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.Vice_President_Vote WHERE T1.age = 18
SELECT DISTINCT T1.Fname ,  T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.VICE_President_VOTE WHERE T1.age  =  18
Final question: Find the first and last name of all the students of age 18 who have vice president votes.
Final SQL: SELECT DISTINCT T1.Fname ,  T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.VICE_President_VOTE WHERE T1.age  =  18
Database: voter_2
Question sequence:
How many students have class senator votes?
How many of those votes are from the fall election cycle?
How many are for male students?
SQL query sequence:
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T2.Election_Cycle  =  "Fall"
SELECT count(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T1.Sex  =  "M" AND T2.Election_Cycle  =  "Fall"
Final question: How many male (sex is M) students have class senator votes in the fall election cycle?
Final SQL: SELECT count(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T1.Sex  =  "M" AND T2.Election_Cycle  =  "Fall"
Database: voter_2
Question sequence:
Count the number of students whose city code is NYC.
What are their names?
How many of those students have class senator votes?
How many of those votes are from the spring election cycle?
SQL query sequence:
SELECT count(*) FROM STUDENT WHERE city_code  =  "NYC"
SELECT FName, LName FROM STUDENT WHERE city_code  =  "NYC"
SELECT count(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T1.city_code  =  "NYC"
SELECT count(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T1.city_code  =  "NYC" AND T2.Election_Cycle  =  "Spring"
Final question: Find the number of students whose city code is NYC and who have class senator votes in the spring election cycle.
Final SQL: SELECT count(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  Class_Senator_Vote WHERE T1.city_code  =  "NYC" AND T2.Election_Cycle  =  "Spring"
Database: voter_2
Question sequence:
Count the number of students whose city code is NYC.
How many have secretary votes?
Which of those students have votes from the spring election cycle? List their names.
What is their average age?
SQL query sequence:
SELECT count(*) FROM STUDENT WHERE city_code  =  "NYC"
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.city_code  =  "NYC"
SELECT DISTINCT T1.FName, T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.city_code  =  "NYC" AND T2.Election_Cycle  =  "Spring"
SELECT avg(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.city_code  =  "NYC" AND T2.Election_Cycle  =  "Spring"
Final question: Find the average age of students who live in the city with code "NYC" and have secretary votes in the spring election cycle.
Final SQL: SELECT avg(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.city_code  =  "NYC" AND T2.Election_Cycle  =  "Spring"
Database: voter_2
Question sequence:
How many female students are there?
How many have secretary votes?
Which of them have votes from the spring election cycle? List their names.
What is their average age?
SQL query sequence:
SELECT count(*) FROM STUDENT WHERE Sex  =  "F"
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.sex  =  "F"
SELECT count(DISTINCT T1.StuID) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.sex  =  "F" AND T2.Election_cycle = "Spring"
SELECT avg(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.Sex  =  "F" AND T2.Election_Cycle  =  "Spring"
Final question: Find the average age of female (sex is F) students who have secretary votes in the spring election cycle.
Final SQL: SELECT avg(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  SECRETARY_Vote WHERE T1.Sex  =  "F" AND T2.Election_Cycle  =  "Spring"