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 is the last name of the youngest student?
assistant
SELECT LName FROM Student WHERE age = (SELECT min(age) FROM Student)
human
Show the student id of the oldest student.
assistant
SELECT StuID FROM Student WHERE age = (SELECT max(age) FROM Student)
human
Show student ids for all male students.
assistant
SELECT StuID FROM Student WHERE Sex = 'M'
human
Show all ages and corresponding number of students.
assistant
SELECT age , count(*) FROM Student GROUP BY age
human
Show first name, last name, age for all female students. Their sex is F.
assistant
SELECT Fname , Lname , Age FROM Student WHERE Sex = 'F'
human
Show first name and last name for all students.
assistant
SELECT Fname , Lname FROM Student ;