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
Report all majors that have less than 3 students.
assistant
SELECT Major FROM STUDENT GROUP BY Major HAVING COUNT(*) < 3
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 last names of students with major 50.
assistant
SELECT LName FROM STUDENT WHERE Major = 50
human
Which major has the most students?
assistant
SELECT Major FROM STUDENT GROUP BY major ORDER BY count(*) DESC LIMIT 1
human
What is the most common major among female (sex is F) students?
assistant
SELECT Major FROM STUDENT WHERE Sex = 'F' GROUP BY major ORDER BY count(*) DESC LIMIT 1
human
List the major of each male student.
assistant
SELECT Major FROM STUDENT WHERE Sex = "M" ;