human
Schema:
Apartment_Buildings (building_id, building_short_name, building_full_name, building_description, building_address, building_manager, building_phone)
Apartments (apt_id, building_id, apt_type_code, apt_number, bathroom_count, bedroom_count, room_count)
Apartment_Facilities (apt_id, facility_code)
Guests (guest_id, gender_code, guest_first_name, guest_last_name, date_of_birth)
Apartment_Bookings (apt_booking_id, apt_id, guest_id, booking_status_code, booking_start_date, booking_end_date)
View_Unit_Status (apt_id, apt_booking_id, status_date, available_yn)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the apartment type code that has the largest number of total rooms, together with the number of bathrooms and number of bedrooms.
assistant
SELECT apt_type_code , bathroom_count , bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY sum(room_count) DESC LIMIT 1
human
What is the average number of rooms of apartments with type code 'Studio'?
assistant
SELECT avg(room_count) FROM Apartments WHERE apt_type_code = 'Studio'
human
Show the facility codes of apartments with more than 4 bedrooms.
assistant
SELECT T1.facility_code FROM Apartment_Facilities AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 4
human
Show the total number of rooms of the apartments in the building with short name 'Columbus Square'.
assistant
SELECT sum(T2.room_count) FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id = T2.building_id WHERE T1.building_short_name = 'Columbus Square'
human
Show each apartment type code, and the maximum and minimum number of rooms for each type.
assistant
SELECT apt_type_code , max(room_count) , min(room_count) FROM Apartments GROUP BY apt_type_code
human
Find the total number of rooms in the apartments that have facility code 'Gym'.
assistant
SELECT SUM( T2.room_count ) FROM Apartment_Facilities AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.facility_code = "Gym" ;