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
Find the number of students in total.
assistant
SELECT count(*) FROM STUDENT
human
Find the distinct majors of students who have treasurer votes.
assistant
SELECT DISTINCT T1.Major FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.Treasurer_Vote
human
Find the distinct first names of the students who have class senator votes.
assistant
SELECT DISTINCT T1.Fname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.CLASS_Senator_VOTE
human
Find the distinct last names of the students who have class president votes.
assistant
SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.CLASS_President_VOTE
human
Find the first names of students with age above 22.
assistant
SELECT Fname FROM STUDENT WHERE Age > 22
human
Find the last names of students with major 50.
assistant
SELECT LName FROM STUDENT WHERE Major = 50 ;