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
Which allergy type has least number of allergies?
assistant
SELECT allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) ASC LIMIT 1
human
Which allergy type has most number of allergies?
assistant
SELECT allergytype FROM Allergy_type GROUP BY allergytype ORDER BY count(*) DESC LIMIT 1
human
Show all allergies and their types.
assistant
SELECT allergy , allergytype FROM Allergy_type
human
Show all allergy types and the number of allergies in each type.
assistant
SELECT allergytype , count(*) FROM Allergy_type GROUP BY allergytype
human
Show all allergy types.
assistant
SELECT DISTINCT allergytype FROM Allergy_type
human
What are the allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names.
assistant
SELECT T1.Allergy , T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" ORDER BY T1.Allergy ;