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 all cities and corresponding number of students.
assistant
SELECT city_code , count(*) FROM Student GROUP BY city_code
human
Show first name and last name for all students.
assistant
SELECT Fname , Lname FROM Student
human
How many students live in HKG or CHI?
assistant
SELECT count(*) FROM Student WHERE city_code = 'HKG' OR city_code = 'CHI'
human
Show all cities where students live.
assistant
SELECT DISTINCT city_code 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
Which city does the student whose last name is 'Kim' live in?
assistant
SELECT city_code FROM Student WHERE LName = "Kim" ;