human
Schema:
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Voting_record (StuID, Registration_Date, Election_Cycle, President_Vote, Vice_President_Vote, Secretary_Vote, Treasurer_Vote, Class_President_Vote, Class_Senator_Vote)
Please answer with SQL.
assistant
Sure, I understand.
human
How many female students are there?
assistant
SELECT COUNT( * ) FROM STUDENT WHERE Sex = 'F';
human
How many have secretary votes?
assistant
SELECT COUNT( DISTINCT T1.StuID ) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = SECRETARY_Vote WHERE T1.sex = 'F';
human
Which of them have votes from the spring election cycle? List their names.
assistant
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';
human
What is their average age?
assistant
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" ;