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
What are the student ids of students who don't have any allergies?
assistant
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy
human
Show all ages and corresponding number of students.
assistant
SELECT age , count(*) FROM Student GROUP BY age
human
Show the student id of the oldest student.
assistant
SELECT StuID FROM Student WHERE age = (SELECT max(age) FROM Student)
human
How many students are age 18?
assistant
SELECT count(*) FROM Student WHERE age = 18
human
Show student ids for all male students.
assistant
SELECT StuID FROM Student WHERE Sex = 'M'
human
What are the student ids for students over 20 years old?
assistant
SELECT StuID FROM Student WHERE age > 20 ;