Database: voter_2

Question: What are the maximum and minimum age of students with major 600?
SQL: SELECT max(Age) ,  min(Age) FROM STUDENT WHERE Major  =  600

Question: Find the distinct ages of students who have secretary votes in the fall election cycle.
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"

Question: Find the distinct Advisor of students who have treasurer votes in the spring election cycle.
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"

Question: Find the first and last names of all the female (sex is F) students who have president votes.
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"

Question: Find the first and last name of all the students of age 18 who have vice president votes.
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

Question: How many male (sex is M) students have class senator votes in the fall election cycle?
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"

Question: Find the number of students whose city code is NYC and who have class senator votes in the spring election cycle.
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"

Question: Find the average age of students who live in the city with code "NYC" and have secretary votes in the spring election cycle.
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"

Question: Find the average age of female (sex is F) students who have secretary votes in the spring election cycle.
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"

Question: Find the distinct first names of all the students who have vice president votes and whose city code is not PIT.
SQL: SELECT DISTINCT T1.Fname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  T2.VICE_PRESIDENT_Vote EXCEPT SELECT DISTINCT Fname FROM STUDENT WHERE city_code  =  "PIT"

Question: Find the distinct last names of all the students who have president votes and whose advisor is not 2192.
SQL: SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  PRESIDENT_Vote EXCEPT SELECT DISTINCT LName FROM STUDENT WHERE Advisor  =  "2192"

Question: Find the distinct last names of all the students who have president votes and whose advisor is 8741.
SQL: SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID  =  PRESIDENT_Vote INTERSECT SELECT DISTINCT LName FROM STUDENT WHERE Advisor  =  "8741"