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 different types of allergies are there?
assistant
SELECT COUNT( distinct allergy ) FROM Has_allergy;
human
What allergy is most prevalent among students?
assistant
SELECT ALLERGY FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.STUID = T2.STUID GROUP BY ALLERGY ORDER BY COUNT( * ) DESC LIMIT 1;
human
How many male students have a tree pollen allergy?
assistant
SELECT COUNT( * ) FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.STUID = T2.STUID WHERE ALLERGY = 'Tree Pollen' AND t1.sex = 'M';
human
How many students have a soy allergy?
assistant
SELECT COUNT( * ) FROM Student WHERE StuID IN ( SELECT StuID FROM Has_allergy WHERE Allergy = 'Soy' );
human
How many students don't have a soy allergy?
assistant
SELECT COUNT( * ) FROM Student WHERE StuID NOT IN ( SELECT StuID FROM Has_allergy WHERE Allergy = 'Soy' );
human
Can you list them for me with their names and majors? | First name? | Yes please. First name and major.
assistant
SELECT fname , major FROM Student WHERE StuID NOT IN ( SELECT StuID FROM Has_allergy WHERE Allergy = "Soy" ) ;