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 maximum age of all the students.
assistant
SELECT max(Age) FROM STUDENT
human
Find the last names of students with major 50.
assistant
SELECT LName FROM STUDENT WHERE Major = 50
human
Find the number of students in total.
assistant
SELECT count(*) FROM STUDENT
human
Find the major that is studied by the largest number of students.
assistant
SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1 ;