Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment numbers, start dates, and end dates of all the apartment bookings. [/INST]

Output: SELECT T2.apt_number ,  T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the apartment number, start date, and end date of each apartment booking? [/INST]

Output: SELECT T2.apt_number ,  T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the booking start and end dates of the apartments with type code "Duplex"? [/INST]

Output: 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.apt_type_code  =  "Duplex";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Return the booking start date and end date for the apartments that have type code "Duplex". [/INST]

Output: 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.apt_type_code  =  "Duplex";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the booking start and end dates of the apartments with more than 2 bedrooms? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Find the booking start date and end date for the apartments that have more than two bedrooms. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What is the booking status code of the apartment with apartment number "Suite 634"? [/INST]

Output: SELECT T1.booking_status_code FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.apt_number  =  "Suite 634";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Tell me the booking status code for the apartment with number "Suite 634". [/INST]

Output: SELECT T1.booking_status_code FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.apt_number  =  "Suite 634";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the distinct apartment numbers of the apartments that have bookings with status code "Confirmed". [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartments have bookings with status code "Confirmed"? Return their apartment numbers. [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the average room count of the apartments that have booking status code "Provisional". [/INST]

Output: SELECT avg(room_count) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T1.booking_status_code  =  "Provisional";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average room count of the apartments whose booking status code is "Provisional"? [/INST]

Output: SELECT avg(room_count) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T1.booking_status_code  =  "Provisional";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the guest first names, start dates, and end dates of all the apartment bookings. [/INST]

Output: SELECT T2.guest_first_name ,  T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the guest first name, start date, and end date of each apartment booking? [/INST]

Output: SELECT T2.guest_first_name ,  T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the start dates and end dates of all the apartment bookings made by guests with gender code "Female". [/INST]

Output: SELECT T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id WHERE T2.gender_code  =  "Female";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the start date and end date of the apartment bookings made by female guests (gender code "Female")? [/INST]

Output: SELECT T1.booking_start_date ,  T1.booking_start_date FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id WHERE T2.gender_code  =  "Female";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the first names and last names of all the guests that have apartment bookings with status code "Confirmed". [/INST]

Output: SELECT T2.guest_first_name ,  T2.guest_last_name FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id WHERE T1.booking_status_code  =  "Confirmed";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which guests have apartment bookings with status code "Confirmed"? Return their first names and last names. [/INST]

Output: SELECT T2.guest_first_name ,  T2.guest_last_name FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id  =  T2.guest_id WHERE T1.booking_status_code  =  "Confirmed";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the facility codes of apartments with more than 4 bedrooms. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the facility codes of the apartments with more than four bedrooms? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the total number of rooms of all apartments with facility code "Gym". [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Find the total number of rooms in the apartments that have facility code "Gym". [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the total number of rooms of the apartments in the building with short name "Columbus Square". [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: How many rooms in total are there in the apartments in the building with short name "Columbus Square"? [/INST]

Output: 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";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the addresses of the buildings that have apartments with more than 2 bathrooms. [/INST]

Output: SELECT T1.building_address FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id  =  T2.building_id WHERE T2.bathroom_count  >  2;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which buildings have apartments that have more than two bathrooms? Give me the addresses of the buildings. [/INST]

Output: SELECT T1.building_address FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id  =  T2.building_id WHERE T2.bathroom_count  >  2;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment type codes and apartment numbers in the buildings managed by "Kyle". [/INST]

Output: SELECT T2.apt_type_code ,  T2.apt_number FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id  =  T2.building_id WHERE T1.building_manager  =  "Kyle";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What apartment type codes and apartment numbers do the buildings managed by "Kyle" have? [/INST]

Output: SELECT T2.apt_type_code ,  T2.apt_number FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id  =  T2.building_id WHERE T1.building_manager  =  "Kyle";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the booking status code and the corresponding number of bookings. [/INST]

Output: SELECT 	booking_status_code ,  COUNT(*) FROM Apartment_Bookings GROUP BY booking_status_code;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: How many bookings does each booking status have? List the booking status code and the number of corresponding bookings. [/INST]

Output: SELECT 	booking_status_code ,  COUNT(*) FROM Apartment_Bookings GROUP BY booking_status_code;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Return all the apartment numbers sorted by the room count in ascending order. [/INST]

Output: SELECT apt_number FROM Apartments ORDER BY room_count ASC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Sort the apartment numbers in ascending order of room count. [/INST]

Output: SELECT apt_number FROM Apartments ORDER BY room_count ASC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Return the apartment number with the largest number of bedrooms. [/INST]

Output: SELECT apt_number FROM Apartments ORDER BY bedroom_count DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What is the apartment number of the apartment with the most beds? [/INST]

Output: SELECT apt_number FROM Apartments ORDER BY bedroom_count DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment type codes and the corresponding number of apartments sorted by the number of apartments in ascending order. [/INST]

Output: SELECT apt_type_code ,  COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Return each apartment type code with the number of apartments having that apartment type, in ascending order of the number of apartments. [/INST]

Output: SELECT apt_type_code ,  COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the top 3 apartment type codes sorted by the average number of rooms in descending order. [/INST]

Output: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY avg(room_count) DESC LIMIT 3;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: What are the top three apartment types in terms of the average room count? Give me the [/INST]

Output: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY avg(room_count) DESC LIMIT 3;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment type code that has the largest number of total rooms, together with the number of bathrooms and number of bedrooms. [/INST]

Output: SELECT apt_type_code ,  bathroom_count ,  bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY sum(room_count) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartment type has the largest number of total rooms? Return the apartment type code, its number of bathrooms and number of bedrooms. [/INST]

Output: SELECT apt_type_code ,  bathroom_count ,  bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY sum(room_count) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the most common apartment type code. [/INST]

Output: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartment type code appears the most often? [/INST]

Output: SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the most common apartment type code among apartments with more than 1 bathroom. [/INST]

Output: SELECT apt_type_code FROM Apartments WHERE bathroom_count  >  1 GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartment type code is the most common among apartments with more than one bathroom? [/INST]

Output: SELECT apt_type_code FROM Apartments WHERE bathroom_count  >  1 GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show each apartment type code, and the maximum and minimum number of rooms for each type. [/INST]

Output: SELECT apt_type_code ,  max(room_count) ,  min(room_count) FROM Apartments GROUP BY apt_type_code;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Return each apartment type code along with the maximum and minimum number of rooms among each type. [/INST]

Output: SELECT apt_type_code ,  max(room_count) ,  min(room_count) FROM Apartments GROUP BY apt_type_code;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show each gender code and the corresponding count of guests sorted by the count in descending order. [/INST]

Output: SELECT gender_code ,  COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Sort the gender codes in descending order of their corresponding number of guests. Return both the gender codes and counts. [/INST]

Output: SELECT gender_code ,  COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: How many apartments do not have any facility? [/INST]

Output: SELECT count(*) FROM Apartments WHERE apt_id NOT IN (SELECT apt_id FROM Apartment_Facilities);


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of apartments that have no facility. [/INST]

Output: SELECT count(*) FROM Apartments WHERE apt_id NOT IN (SELECT apt_id FROM Apartment_Facilities);


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment numbers of apartments with bookings that have status code both "Provisional" and "Confirmed" [/INST]

Output: SELECT 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" INTERSECT SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T1.booking_status_code  =  "Provisional";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartments have bookings with both status codes "Provisional" and "Confirmed"? Give me the apartment numbers. [/INST]

Output: SELECT 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" INTERSECT SELECT T2.apt_number FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id  =  T2.apt_id WHERE T1.booking_status_code  =  "Provisional";


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Show the apartment numbers of apartments with unit status availability of both 0 and 1. [/INST]

Output: SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.available_yn  =  0 INTERSECT SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.available_yn  =  1;


Input:
[INST] Here is a database schema:
Apartment_Buildings :
building_id [ INT ] primary_key
building_short_name [ TEXT ]
building_full_name [ TEXT ]
building_description [ TEXT ]
building_address [ TEXT ]
building_manager [ TEXT ]
building_phone [ TEXT ]

Apartments :
apt_id [ INT ] primary_key
building_id [ INT ] Apartments.building_id = Apartment_Buildings.building_id
apt_type_code [ TEXT ]
apt_number [ TEXT ]
bathroom_count [ INT ]
bedroom_count [ INT ]
room_count [ TEXT ]

Apartment_Facilities :
apt_id [ INT ] primary_key Apartment_Facilities.apt_id = Apartments.apt_id
facility_code [ TEXT ]

Guests :
guest_id [ INT ] primary_key
gender_code [ TEXT ]
guest_first_name [ TEXT ]
guest_last_name [ TEXT ]
date_of_birth [ TEXT ]

Apartment_Bookings :
apt_booking_id [ INT ] primary_key
apt_id [ INT ] Apartment_Bookings.apt_id = Apartments.apt_id
guest_id [ INT ] Apartment_Bookings.guest_id = Guests.guest_id
booking_status_code [ TEXT ]
booking_start_date [ TEXT ]
booking_end_date [ TEXT ]

View_Unit_Status :
apt_id [ INT ] View_Unit_Status.apt_id = Apartments.apt_id
apt_booking_id [ INT ] View_Unit_Status.apt_booking_id = Apartment_Bookings.apt_booking_id
status_date [ TEXT ] primary_key
available_yn [ TEXT ]

Please write me a SQL statement that answers the following question: Which apartments have unit status availability of both 0 and 1? Return their apartment numbers. [/INST]

Output: SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.available_yn  =  0 INTERSECT SELECT T1.apt_number FROM Apartments AS T1 JOIN View_Unit_Status AS T2 ON T1.apt_id  =  T2.apt_id WHERE T2.available_yn  =  1;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: How many games are held after season 2007? [/INST]

Output: SELECT count(*) FROM game WHERE season  >  2007;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: List the dates of games by the home team name in descending order. [/INST]

Output: SELECT Date FROM game ORDER BY home_team DESC;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: List the season, home team, away team of all the games. [/INST]

Output: SELECT season ,  home_team ,  away_team FROM game;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What are the maximum, minimum and average home games each stadium held? [/INST]

Output: SELECT max(home_games) ,  min(home_games) ,  avg(home_games) FROM stadium;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average attendance of stadiums with capacity percentage higher than 100%? [/INST]

Output: SELECT average_attendance FROM stadium WHERE capacity_percentage  >  100;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What are the player name, number of matches, and information source for players who do not suffer from injury of 'Knee problem'? [/INST]

Output: SELECT player ,  number_of_matches ,  SOURCE FROM injury_accident WHERE injury != 'Knee problem';


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What is the season of the game which causes the player 'Walter Samuel' to get injured? [/INST]

Output: SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id WHERE T2.player  =  'Walter Samuel';


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids, scores, and dates of the games which caused at least two injury accidents? [/INST]

Output: SELECT T1.id ,  T1.score ,  T1.date FROM game AS T1 JOIN injury_accident AS T2 ON T2.game_id  =  T1.id GROUP BY T1.id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: What are the id and name of the stadium where the most injury accidents happened? [/INST]

Output: SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: Find the id and name of the stadium where the largest number of injury accidents occurred. [/INST]

Output: SELECT T1.id ,  T1.name FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id JOIN injury_accident AS T3 ON T2.id  =  T3.game_id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'? [/INST]

Output: SELECT T1.season ,  T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.injury  =  'Foot injury' OR T3.injury  =  'Knee problem';


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: How many different kinds of information sources are there for injury accidents? [/INST]

Output: SELECT count(DISTINCT SOURCE) FROM injury_accident;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: How many games are free of injury accidents? [/INST]

Output: SELECT count(*) FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident );


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: How many distinct kinds of injuries happened after season 2010? [/INST]

Output: SELECT count(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id  =  T2.id WHERE T2.season  >  2010;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: List the name of the stadium where both the player 'Walter Samuel' and the player 'Thiago Motta' got injured. [/INST]

Output: SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Walter Samuel' INTERSECT SELECT T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id WHERE T3.player  =  'Thiago Motta';


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: Show the name, average attendance, total attendance for stadiums where no accidents happened. [/INST]

Output: SELECT name ,  average_attendance ,  total_attendance FROM stadium EXCEPT SELECT T2.name ,  T2.average_attendance ,  T2.total_attendance FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id  =  T2.id JOIN injury_accident AS T3 ON T1.id  =  T3.game_id;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: Which stadium name contains the substring "Bank"? [/INST]

Output: SELECT name FROM stadium WHERE name LIKE "%Bank%";


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: How many games has each stadium held? [/INST]

Output: SELECT T1.id ,  count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id  =  T2.stadium_id GROUP BY T1.id;


Input:
[INST] Here is a database schema:
stadium :
id [ INT ] primary_key
name [ TEXT ]
Home_Games [ INT ]
Average_Attendance [ INT ]
Total_Attendance [ INT ]
Capacity_Percentage [ INT ]

game :
stadium_id [ INT ] game.stadium_id = stadium.id
id [ INT ] primary_key
Season [ INT ]
Date [ TEXT ]
Home_team [ TEXT ]
Away_team [ TEXT ]
Score [ TEXT ]
Competition [ TEXT ]

injury_accident :
game_id [ INT ] injury_accident.game_id = game.id
id [ INT ] primary_key
Player [ TEXT ]
Injury [ TEXT ]
Number_of_matches [ TEXT ]
Source [ TEXT ]

Please write me a SQL statement that answers the following question: For each injury accident, find the date of the game and the name of the injured player in the game, and sort the results in descending order of game season. [/INST]

Output: SELECT T1.date ,  T2.player FROM game AS T1 JOIN injury_accident AS T2 ON T1.id  =  T2.game_id ORDER BY T1.season DESC;