human
Schema:
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Restaurant (ResID, ResName, Address, Rating)
Type_Of_Restaurant (ResID, ResTypeID)
Restaurant_Type (ResTypeID, ResTypeName, ResTypeDescription)
Visits_Restaurant (StuID, ResID, Time, Spent)
Please answer with SQL.
assistant
Sure, I understand.
human
Which major has between 2 and 30 number of students? List major and the number of students.
assistant
SELECT Major , COUNT( * ) FROM Student GROUP BY Major HAVING COUNT( Major ) BETWEEN 2 AND 30;
human
Which major has highest number of students?List the students First name?
assistant
SELECT Major , Fname FROM Student WHERE major = ( SELECT major FROM student GROUP by major ORDER by COUNT( * ) desc LIMIT 1 );
human
Which major has least number of students?List the students First name?
assistant
SELECT Major , Fname FROM Student WHERE major = ( SELECT major FROM student GROUP by major ORDER by COUNT( * ) asc LIMIT 1 ) ;