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 age 18?
assistant
SELECT count(*) FROM Student WHERE age = 18
human
Which major has most number of students?
assistant
SELECT major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1
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
How many students are there?
assistant
SELECT count(*) FROM Student
human
How many students live in each city?
assistant
SELECT city_code , COUNT( * ) FROM Student GROUP BY city_code ;