human
Schema:
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Dorm (dormid, dorm_name, student_capacity, gender)
Dorm_amenity (amenid, amenity_name)
Has_amenity (dormid, amenid)
Lives_in (stuid, dormid, room_number)
Please answer with SQL.
assistant
Sure, I understand.
human
Which dorm has the largest capacity? | Hi do you need the dorm name or dorm id ? | dorm id , please.
assistant
SELECT dormid FROM dorm ORDER BY student_capacity DESC LIMIT 1;
human
How many students live there?
assistant
SELECT COUNT( T1.stuid ) FROM lives_in AS T1 JOIN dorm AS T2 ON T1.dormid = T2.dormid WHERE T2.student_capacity = ( SELECT MAX( student_capacity ) FROM dorm );
human
What is their average age?
assistant
SELECT AVG ( T1.age ) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = ( SELECT MAX( student_capacity ) FROM dorm ) ;