human
Schema:
Allergy_Type (Allergy, AllergyType)
Has_Allergy (StuID, Allergy)
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Please answer with SQL.
assistant
Sure, I understand.
human
Show first name and last name for all students.
assistant
SELECT Fname , Lname FROM Student
human
How many different advisors are listed?
assistant
SELECT count(DISTINCT advisor) FROM Student
human
Show all cities and corresponding number of students.
assistant
SELECT city_code , count(*) FROM Student GROUP BY city_code
human
Show all ages and corresponding number of students.
assistant
SELECT age , count(*) FROM Student GROUP BY age
human
Which advisor has most number of students?
assistant
SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1
human
Show all advisors and corresponding number of students.
assistant
SELECT advisor , COUNT( * ) FROM Student GROUP BY advisor ;