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
What is the average age of female (sex is F) students?
assistant
SELECT avg(Age) FROM STUDENT WHERE Sex = 'F'
human
What is the city_code of the city that the most students live in?
assistant
SELECT city_code FROM STUDENT GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
human
Find the last names of students with major 50.
assistant
SELECT LName FROM STUDENT WHERE Major = 50
human
Find the maximum age of all the students.
assistant
SELECT max(Age) FROM STUDENT
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 there in total?
assistant
SELECT COUNT( * ) FROM STUDENT ;