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 different allergy types?
assistant
SELECT DISTINCT allergytype FROM Allergy_type;
human
For each, how many students does it affect?
assistant
SELECT T2.allergytype , COUNT( * ) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy = T2.allergy GROUP BY T2.allergytype ;