Can you list all student IDs that have any kind of allergy?
select stuid from has_allergy
Can you filter the list to only show student IDs that have food and animal type allergies?
select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "food" intersect select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "animal"
Can you display the ages associated with those student IDs?
select age from student where stuid in ( select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "food" intersect select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "animal" )
What is the average of those 3 ages?
select avg ( age ) from student where stuid in ( select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "food" intersect select t1.stuid from has_allergy as t1 join allergy_type as t2 on t1.allergy = t2.allergy where t2.allergytype = "animal" )