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
How many students are there?
assistant
SELECT count(*) FROM Student
human
What is the last name of the youngest student?
assistant
SELECT LName FROM Student WHERE age = (SELECT min(age) FROM Student)
human
Show all ages and corresponding number of students.
assistant
SELECT age , count(*) FROM Student GROUP BY age
human
Show the average age for male and female students.
assistant
SELECT avg(age) , sex FROM Student GROUP BY sex
human
How many students are age 18?
assistant
SELECT count(*) FROM Student WHERE age = 18
human
What is the minimum, mean, and maximum age across all students?
assistant
SELECT MIN( age ) , avg ( age ) , MAX( age ) FROM Student ;