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
Which major has the most students?
assistant
SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1;
human
How many students are in that major?
assistant
SELECT COUNT( * ) FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1;
human
What are their names, please?
assistant
SELECT LName , Fname FROM student WHERE major IN ( SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1 );
human
Who is the advisor for that major?
assistant
SELECT advisor FROM student WHERE major = ( SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1 );
human
Who is the advisor for the major with the second most number of students?
assistant
SELECT advisor FROM student WHERE major IN ( SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 2 ) AND major ! = ( SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT( * ) DESC LIMIT 1 ) ;