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
How many apartments do not have any facility?
assistant
SELECT count(*) FROM Apartments WHERE apt_id NOT IN (SELECT apt_id FROM Apartment_Facilities)
human
Show the distinct apartment numbers of the apartments that have bookings with status code 'Confirmed'.
assistant
SELECT DISTINCT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T1.booking_status_code = 'Confirmed'
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
What is the average number of bedrooms of all apartments?
assistant
SELECT avg(bedroom_count) FROM Apartments
human
What are the booking start and end dates of the apartments with more than 2 bedrooms?
assistant
SELECT T1.booking_start_date , T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 2
human
How many apartment bookings are there in total?
assistant
SELECT COUNT( * ) FROM Apartment_Bookings ;