CREATE TABLE Student (age NUMBER, StuID VARCHAR2)
CREATE TABLE Allergy_Type (Allergy VARCHAR2, allergytype VARCHAR2)
CREATE TABLE Has_allergy (StuID VARCHAR2, Allergy VARCHAR2)

Find the average age of the students who have allergies with food and animal types.
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")
WITH "_u_0" AS (SELECT ARRAY_AGG("StuID") AS "", "T2"."allergytype" AS "_u_1" FROM "Has_allergy" "T1" JOIN "Allergy_Type" "T2" ON "T1"."Allergy" = "T2"."Allergy" GROUP BY "T2"."allergytype") SELECT AVG("age") FROM "Student" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."_u_1" = "food" WHERE ARRAY_ANY("_u_0"."", "_x" -> "StuID" = "_x")