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
How many students are there?
assistant
SELECT count(*) FROM student
human
Find the number of amenities for each of the dorms that can accommodate more than 100 students.
assistant
SELECT count(*) , T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
human
Find the number of dorms and total capacity for each gender.
assistant
SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender
human
Find the name of dorms that can accommodate more than 300 students.
assistant
SELECT dorm_name FROM dorm WHERE student_capacity > 300
human
How many dorms are there?
assistant
SELECT count(*) FROM dorm
human
What is the total student capacity of all dorms?
assistant
SELECT SUM( student_capacity ) FROM dorm ;