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
Oh, sorry. I meant to ask what dorm does the student with the last name of Smith live in?
assistant
SELECT T1.dorm_name FROM dorm AS T1 JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith';
human
What are the amenities of those dorms?
assistant
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith';
human
What are the amenities of the dorm that the student with the last name of Jones lives in?
assistant
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Jones';
human
What are the amenities of the dorm that the oldest student lives in?
assistant
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.age = ( SELECT MAX( age ) FROM student );
human
What are the amenities of the dorm that has the most female students living in it?
assistant
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T1.dormid = ( SELECT T1.dormid FROM dorm AS T1 JOIN lives_in AS T4 ON T1.dormid = T4.dormid JOIN student AS T5 ON T4.stuid = T5.stuid WHERE T5.sex = 'F' GROUP by T1.dormid ORDER by COUNT( * ) desc LIMIT 1 );
human
What are the amenities of the dorm that has the smallest student capacity?
assistant
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.student_capacity = ( SELECT MIN( student_capacity ) FROM dorm ) ;