db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
apartment_rentals
Show the short names of the buildings managed by "Emma".
SELECT building_short_name FROM Apartment_Buildings WHERE building_manager = "Emma"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which buildings does "Emma" manage? Give me the short names of the buildings.
SELECT building_short_name FROM Apartment_Buildings WHERE building_manager = "Emma"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the addresses and phones of all the buildings managed by "Brenden".
SELECT building_address , building_phone FROM Apartment_Buildings WHERE building_manager = "Brenden"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the address and phone number of the buildings managed by "Brenden"?
SELECT building_address , building_phone FROM Apartment_Buildings WHERE building_manager = "Brenden"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the building full names that contain the word "court"?
SELECT building_full_name FROM Apartment_Buildings WHERE building_full_name LIKE "%court%"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find all the building full names containing the word "court".
SELECT building_full_name FROM Apartment_Buildings WHERE building_full_name LIKE "%court%"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the minimum and maximum number of bathrooms of all the apartments?
SELECT min(bathroom_count) , max(bathroom_count) FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Give me the minimum and maximum bathroom count among all the apartments.
SELECT min(bathroom_count) , max(bathroom_count) FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the average number of bedrooms of all apartments?
SELECT avg(bedroom_count) FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find the average number of bedrooms of all the apartments.
SELECT avg(bedroom_count) FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the apartment number and the number of rooms for each apartment.
SELECT apt_number , room_count FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the apartment number and the room count of each apartment?
SELECT apt_number , room_count FROM Apartments
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the average number of rooms of apartments with type code "Studio"?
SELECT avg(room_count) FROM Apartments WHERE apt_type_code = "Studio"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find the average room count of the apartments that have the "Studio" type code.
SELECT avg(room_count) FROM Apartments WHERE apt_type_code = "Studio"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the apartment numbers of the apartments with type code "Flat".
SELECT apt_number FROM Apartments WHERE apt_type_code = "Flat"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartments have type code "Flat"? Give me their apartment numbers.
SELECT apt_number FROM Apartments WHERE apt_type_code = "Flat"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the first names and last names of all guests
SELECT guest_first_name , guest_last_name FROM Guests
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the first names and last names of all the guests?
SELECT guest_first_name , guest_last_name FROM Guests
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the date of birth for all the guests with gender code "Male".
SELECT date_of_birth FROM Guests WHERE gender_code = "Male"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are dates of birth of all the guests whose gender is "Male"?
SELECT date_of_birth FROM Guests WHERE gender_code = "Male"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment numbers, start dates, and end dates of all the apartment bookings.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the apartment number, start date, and end date of each apartment booking?
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the booking start and end dates of the apartments with type code "Duplex"?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the booking start date and end date for the apartments that have type code "Duplex".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the booking start and end dates of the apartments with more than 2 bedrooms?
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find the booking start date and end date for the apartments that have more than two bedrooms.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the booking status code of the apartment with apartment number "Suite 634"?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Tell me the booking status code for the apartment with number "Suite 634".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the distinct apartment numbers of the apartments that have bookings with status code "Confirmed".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartments have bookings with status code "Confirmed"? Return their apartment numbers.
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the average room count of the apartments that have booking status code "Provisional".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the average room count of the apartments whose booking status code is "Provisional"?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the guest first names, start dates, and end dates of all the apartment bookings.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the guest first name, start date, and end date of each apartment booking?
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the start dates and end dates of all the apartment bookings made by guests with gender code "Female".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the start date and end date of the apartment bookings made by female guests (gender code "Female")?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the first names and last names of all the guests that have apartment bookings with status code "Confirmed".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which guests have apartment bookings with status code "Confirmed"? Return their first names and last names.
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the facility codes of apartments with more than 4 bedrooms.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the facility codes of the apartments with more than four bedrooms?
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the total number of rooms of all apartments with facility code "Gym".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find the total number of rooms in the apartments that have facility code "Gym".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the total number of rooms of the apartments in the building with short name "Columbus Square".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
How many rooms in total are there in the apartments in the building with short name "Columbus Square"?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the addresses of the buildings that have apartments with more than 2 bathrooms.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which buildings have apartments that have more than two bathrooms? Give me the addresses of the buildings.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment type codes and apartment numbers in the buildings managed by "Kyle".
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What apartment type codes and apartment numbers do the buildings managed by "Kyle" have?
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the booking status code and the corresponding number of bookings.
SELECT booking_status_code , COUNT(*) FROM Apartment_Bookings GROUP BY booking_status_code
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
How many bookings does each booking status have? List the booking status code and the number of corresponding bookings.
SELECT booking_status_code , COUNT(*) FROM Apartment_Bookings GROUP BY booking_status_code
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return all the apartment numbers sorted by the room count in ascending order.
SELECT apt_number FROM Apartments ORDER BY room_count ASC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Sort the apartment numbers in ascending order of room count.
SELECT apt_number FROM Apartments ORDER BY room_count ASC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return the apartment number with the largest number of bedrooms.
SELECT apt_number FROM Apartments ORDER BY bedroom_count DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What is the apartment number of the apartment with the most beds?
SELECT apt_number FROM Apartments ORDER BY bedroom_count DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment type codes and the corresponding number of apartments sorted by the number of apartments in ascending order.
SELECT apt_type_code , COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return each apartment type code with the number of apartments having that apartment type, in ascending order of the number of apartments.
SELECT apt_type_code , COUNT(*) FROM Apartments GROUP BY apt_type_code ORDER BY COUNT(*) ASC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the top 3 apartment type codes sorted by the average number of rooms in descending order.
SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY avg(room_count) DESC LIMIT 3
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
What are the top three apartment types in terms of the average room count? Give me the
SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY avg(room_count) DESC LIMIT 3
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment type code that has the largest number of total rooms, together with the number of bathrooms and number of bedrooms.
SELECT apt_type_code , bathroom_count , bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY sum(room_count) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartment type has the largest number of total rooms? Return the apartment type code, its number of bathrooms and number of bedrooms.
SELECT apt_type_code , bathroom_count , bedroom_count FROM Apartments GROUP BY apt_type_code ORDER BY sum(room_count) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the most common apartment type code.
SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartment type code appears the most often?
SELECT apt_type_code FROM Apartments GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the most common apartment type code among apartments with more than 1 bathroom.
SELECT apt_type_code FROM Apartments WHERE bathroom_count > 1 GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartment type code is the most common among apartments with more than one bathroom?
SELECT apt_type_code FROM Apartments WHERE bathroom_count > 1 GROUP BY apt_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show each apartment type code, and the maximum and minimum number of rooms for each type.
SELECT apt_type_code , max(room_count) , min(room_count) FROM Apartments GROUP BY apt_type_code
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Return each apartment type code along with the maximum and minimum number of rooms among each type.
SELECT apt_type_code , max(room_count) , min(room_count) FROM Apartments GROUP BY apt_type_code
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show each gender code and the corresponding count of guests sorted by the count in descending order.
SELECT gender_code , COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Sort the gender codes in descending order of their corresponding number of guests. Return both the gender codes and counts.
SELECT gender_code , COUNT(*) FROM Guests GROUP BY gender_code ORDER BY COUNT(*) DESC
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
How many apartments do not have any facility?
SELECT count(*) FROM Apartments WHERE apt_id NOT IN (SELECT apt_id FROM Apartment_Facilities)
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Find the number of apartments that have no facility.
SELECT count(*) FROM Apartments WHERE apt_id NOT IN (SELECT apt_id FROM Apartment_Facilities)
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment numbers of apartments with bookings that have status code both "Provisional" and "Confirmed"
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartments have bookings with both status codes "Provisional" and "Confirmed"? Give me the apartment numbers.
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"
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Show the apartment numbers of apartments with unit status availability of both 0 and 1.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
apartment_rentals
Which apartments have unit status availability of both 0 and 1? Return their apartment numbers.
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
CREATE TABLE Apartment_Buildings ( building_id INTEGER NOT NULL, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(50), building_phone VARCHAR(80), PRIMARY KEY (building_id), UNIQUE (building_id) ) 3 rows from Apartment_Buildings table: building_id building_short_name building_full_name building_description building_address building_manager building_phone 133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176\nMarquiseberg, CA 70496 Emma (948)040-1064x387 153 Mercedes House Mercedes House Studio 354 Otto Villages\nCharliefort, VT 71664 Brenden 915-617-2408x832 191 The Eugene The Eugene Flat 71537 Gorczany Inlet\nWisozkburgh, AL 08256 Melyssa (609)946-0491 CREATE TABLE Apartments ( apt_id INTEGER NOT NULL , building_id INTEGER NOT NULL, apt_type_code CHAR(15), apt_number CHAR(10), bathroom_count INTEGER, bedroom_count INTEGER, room_count CHAR(5), PRIMARY KEY (apt_id), UNIQUE (apt_id), FOREIGN KEY (building_id) REFERENCES Apartment_Buildings (building_id) ) 3 rows from Apartments table: apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count 1 808 Flat Suite 645 1 3 7 2 624 Flat Apt. 585 2 4 5 3 225 Studio Apt. 908 1 6 7 CREATE TABLE Apartment_Facilities ( apt_id INTEGER NOT NULL, facility_code CHAR(15) NOT NULL, PRIMARY KEY (apt_id, facility_code), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id) ) 3 rows from Apartment_Facilities table: apt_id facility_code 1 Boardband 2 Boardband 3 Gym CREATE TABLE Guests ( guest_id INTEGER NOT NULL , gender_code CHAR(1), guest_first_name VARCHAR(80), guest_last_name VARCHAR(80), date_of_birth DATETIME, PRIMARY KEY (guest_id), UNIQUE (guest_id) ) 3 rows from Guests table: guest_id gender_code guest_first_name guest_last_name date_of_birth 1 Male Kip DuBuque 1995-11-04 07:09:57 2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58 3 Female Keon Treutel 1974-08-20 09:28:05 CREATE TABLE Apartment_Bookings ( apt_booking_id INTEGER NOT NULL, apt_id INTEGER, guest_id INTEGER NOT NULL, booking_status_code CHAR(15) NOT NULL, booking_start_date DATETIME, booking_end_date DATETIME, PRIMARY KEY (apt_booking_id), UNIQUE (apt_booking_id), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (guest_id) REFERENCES Guests (guest_id) ) 3 rows from Apartment_Bookings table: apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date 258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48 279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42 337 8 5 Provisional 2017-03-13 16:20:14 2018-02-19 16:59:08 CREATE TABLE View_Unit_Status ( apt_id INTEGER, apt_booking_id INTEGER, status_date DATETIME NOT NULL, available_yn BIT, PRIMARY KEY (status_date), FOREIGN KEY (apt_id) REFERENCES Apartments (apt_id), FOREIGN KEY (apt_booking_id) REFERENCES Apartment_Bookings (apt_booking_id) ) 3 rows from View_Unit_Status table: apt_id apt_booking_id status_date available_yn 11 920 1970-09-28 10:24:29 1 15 575 1972-03-23 22:55:53 1 15 924 1973-10-28 04:30:14 1
game_injury
How many games are held after season 2007?
SELECT count(*) FROM game WHERE season > 2007
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
List the dates of games by the home team name in descending order.
SELECT Date FROM game ORDER BY home_team DESC
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
List the season, home team, away team of all the games.
SELECT season , home_team , away_team FROM game
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What are the maximum, minimum and average home games each stadium held?
SELECT max(home_games) , min(home_games) , avg(home_games) FROM stadium
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What is the average attendance of stadiums with capacity percentage higher than 100%?
SELECT average_attendance FROM stadium WHERE capacity_percentage > 100
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What are the player name, number of matches, and information source for players who do not suffer from injury of 'Knee problem'?
SELECT player , number_of_matches , SOURCE FROM injury_accident WHERE injury != 'Knee problem'
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What is the season of the game which causes the player 'Walter Samuel' to get injured?
SELECT T1.season FROM game AS T1 JOIN injury_accident AS T2 ON T1.id = T2.game_id WHERE T2.player = 'Walter Samuel'
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What are the ids, scores, and dates of the games which caused at least two injury accidents?
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
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
What are the id and name of the stadium where the most injury accidents happened?
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
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
Find the id and name of the stadium where the largest number of injury accidents occurred.
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
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'?
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'
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
How many different kinds of information sources are there for injury accidents?
SELECT count(DISTINCT SOURCE) FROM injury_accident
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
How many games are free of injury accidents?
SELECT count(*) FROM game WHERE id NOT IN ( SELECT game_id FROM injury_accident )
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
How many distinct kinds of injuries happened after season 2010?
SELECT count(DISTINCT T1.injury) FROM injury_accident AS T1 JOIN game AS T2 ON T1.game_id = T2.id WHERE T2.season > 2010
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
List the name of the stadium where both the player 'Walter Samuel' and the player 'Thiago Motta' got injured.
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'
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
Show the name, average attendance, total attendance for stadiums where no accidents happened.
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
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
Which stadium name contains the substring "Bank"?
SELECT name FROM stadium WHERE name LIKE "%Bank%"
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
How many games has each stadium held?
SELECT T1.id , count(*) FROM stadium AS T1 JOIN game AS T2 ON T1.id = T2.stadium_id GROUP BY T1.id
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
game_injury
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.
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
CREATE TABLE "stadium" ( "id" int, "name" text, "Home_Games" int, "Average_Attendance" real, "Total_Attendance" real, "Capacity_Percentage" real, primary key ("id") ) 3 rows from stadium table: id name Home_Games Average_Attendance Total_Attendance Capacity_Percentage 1 Cowboys Stadium 8 87047.0 696377.0 108.8 2 FedExField 8 83172.0 665380.0 90.7 3 New Meadowlands Stadium 8 79019.0 632156.0 95.8 CREATE TABLE "game" ( "stadium_id" int, "id" int, "Season" int, "Date" text, "Home_team" text, "Away_team" text, "Score" text, "Competition" text, primary key ("id"), foreign key ("stadium_id") references `stadium`("id") ) 3 rows from game table: stadium_id id Season Date Home_team Away_team Score Competition 1 1 2007 18 May 2007 Quruvchi Pakhtakor 1–1 League 2 2 2007 22 September 2007 Pakhtakor Quruvchi 0–0 League 3 3 2007 9 December 2007 Pakhtakor Quruvchi 0–0 (7:6) Cup CREATE TABLE "injury_accident" ( "game_id" int, "id" int, "Player" text, "Injury" text, "Number_of_matches" text, "Source" text, primary key ("id"), foreign key ("game_id") references `game`("id") ) 3 rows from injury_accident table: game_id id Player Injury Number_of_matches Source 1 1 Davide Santon Clean-up surgery on his right knee 12 inter.it 2 2 Maicon Knee problem 2 inter.it 3 3 Dejan Stanković Hamstring muscle strain in his left thigh 2 inter.it
soccer_1
List all country and league names.
SELECT T1.name , T2.name FROM Country AS T1 JOIN League AS T2 ON T1.id = T2.country_id
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
How many leagues are there in England?
SELECT count(*) FROM Country AS T1 JOIN League AS T2 ON T1.id = T2.country_id WHERE T1.name = "England"
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
What is the average weight of all players?
SELECT avg(weight) FROM Player
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
What is the maximum and minimum height of all players?
SELECT max(weight) , min(weight) FROM Player
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
List all player names who have an overall rating higher than the average.
SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.overall_rating > ( SELECT avg(overall_rating) FROM Player_Attributes )
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
What are the names of players who have the best dribbling?
SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.dribbling = ( SELECT max(overall_rating) FROM Player_Attributes)
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover
soccer_1
List the names of all players who have a crossing score higher than 90 and prefer their right foot.
SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.crossing > 90 AND T2.preferred_foot = "right"
CREATE TABLE "Player_Attributes" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_fifa_api_id` INTEGER, `player_api_id` INTEGER, `date` TEXT, `overall_rating` INTEGER, `potential` INTEGER, `preferred_foot` TEXT, `attacking_work_rate` TEXT, `defensive_work_rate` TEXT, `crossing` INTEGER, `finishing` INTEGER, `heading_accuracy` INTEGER, `short_passing` INTEGER, `volleys` INTEGER, `dribbling` INTEGER, `curve` INTEGER, `free_kick_accuracy` INTEGER, `long_passing` INTEGER, `ball_control` INTEGER, `acceleration` INTEGER, `sprint_speed` INTEGER, `agility` INTEGER, `reactions` INTEGER, `balance` INTEGER, `shot_power` INTEGER, `jumping` INTEGER, `stamina` INTEGER, `strength` INTEGER, `long_shots` INTEGER, `aggression` INTEGER, `interceptions` INTEGER, `positioning` INTEGER, `vision` INTEGER, `penalties` INTEGER, `marking` INTEGER, `standing_tackle` INTEGER, `sliding_tackle` INTEGER, `gk_diving` INTEGER, `gk_handling` INTEGER, `gk_kicking` INTEGER, `gk_positioning` INTEGER, `gk_reflexes` INTEGER, FOREIGN KEY(`player_fifa_api_id`) REFERENCES `Player`(`player_fifa_api_id`), FOREIGN KEY(`player_api_id`) REFERENCES `Player`(`player_api_id`) ) 3 rows from Player_Attributes table: id player_fifa_api_id player_api_id date overall_rating potential preferred_foot attacking_work_rate defensive_work_rate crossing finishing heading_accuracy short_passing volleys dribbling curve free_kick_accuracy long_passing ball_control acceleration sprint_speed agility reactions balance shot_power jumping stamina strength long_shots aggression interceptions positioning vision penalties marking standing_tackle sliding_tackle gk_diving gk_handling gk_kicking gk_positioning gk_reflexes 1 218353 505942 2016-02-18 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 2 218353 505942 2015-11-19 00:00:00 67 71 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 71 70 45 54 48 65 69 69 6 11 10 8 8 3 218353 505942 2015-09-21 00:00:00 62 66 right medium medium 49 44 71 61 44 51 45 39 64 49 60 64 59 47 65 55 58 54 76 35 63 41 45 54 48 65 66 69 6 11 10 8 8 CREATE TABLE sqlite_sequence(name,seq) 3 rows from sqlite_sequence table: name seq Team 103916 Country 51958 League 51958 CREATE TABLE `Player` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `player_api_id` INTEGER UNIQUE, `player_name` TEXT, `player_fifa_api_id` INTEGER UNIQUE, `birthday` TEXT, `height` INTEGER, `weight` INTEGER ) 3 rows from Player table: id player_api_id player_name player_fifa_api_id birthday height weight 1 505942 Aaron Appindangoye 218353 1992-02-29 00:00:00 182.88 187 2 155782 Aaron Cresswell 189615 1989-12-15 00:00:00 170.18 146 3 162549 Aaron Doran 186170 1991-05-13 00:00:00 170.18 163 CREATE TABLE `League` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `country_id` INTEGER, `name` TEXT UNIQUE, FOREIGN KEY(`country_id`) REFERENCES `Country`(`id`) ) 3 rows from League table: id country_id name 1 1 Belgium Jupiler League 1729 1729 England Premier League 4769 4769 France Ligue 1 CREATE TABLE `Country` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` TEXT UNIQUE ) 3 rows from Country table: id name 1 Belgium 1729 England 4769 France CREATE TABLE "Team" ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_api_id` INTEGER UNIQUE, `team_fifa_api_id` INTEGER, `team_long_name` TEXT, `team_short_name` TEXT ) 3 rows from Team table: id team_api_id team_fifa_api_id team_long_name team_short_name 1 9987 673 KRC Genk GEN 2 9993 675 Beerschot AC BAC 3 10000 15005 SV Zulte-Waregem ZUL CREATE TABLE `Team_Attributes` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `team_fifa_api_id` INTEGER, `team_api_id` INTEGER, `date` TEXT, `buildUpPlaySpeed` INTEGER, `buildUpPlaySpeedClass` TEXT, `buildUpPlayDribbling` INTEGER, `buildUpPlayDribblingClass` TEXT, `buildUpPlayPassing` INTEGER, `buildUpPlayPassingClass` TEXT, `buildUpPlayPositioningClass` TEXT, `chanceCreationPassing` INTEGER, `chanceCreationPassingClass` TEXT, `chanceCreationCrossing` INTEGER, `chanceCreationCrossingClass` TEXT, `chanceCreationShooting` INTEGER, `chanceCreationShootingClass` TEXT, `chanceCreationPositioningClass` TEXT, `defencePressure` INTEGER, `defencePressureClass` TEXT, `defenceAggression` INTEGER, `defenceAggressionClass` TEXT, `defenceTeamWidth` INTEGER, `defenceTeamWidthClass` TEXT, `defenceDefenderLineClass` TEXT, FOREIGN KEY(`team_fifa_api_id`) REFERENCES `Team`(`team_fifa_api_id`), FOREIGN KEY(`team_api_id`) REFERENCES `Team`(`team_api_id`) ) 3 rows from Team_Attributes table: id team_fifa_api_id team_api_id date buildUpPlaySpeed buildUpPlaySpeedClass buildUpPlayDribbling buildUpPlayDribblingClass buildUpPlayPassing buildUpPlayPassingClass buildUpPlayPositioningClass chanceCreationPassing chanceCreationPassingClass chanceCreationCrossing chanceCreationCrossingClass chanceCreationShooting chanceCreationShootingClass chanceCreationPositioningClass defencePressure defencePressureClass defenceAggression defenceAggressionClass defenceTeamWidth defenceTeamWidthClass defenceDefenderLineClass 1 434 9930 2010-02-22 00:00:00 60 Balanced NaN Little 50 Mixed Organised 60 Normal 65 Normal 55 Normal Organised 50 Medium 55 Press 45 Normal Cover 2 434 9930 2014-09-19 00:00:00 52 Balanced 48.0 Normal 56 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover 3 434 9930 2015-09-10 00:00:00 47 Balanced 41.0 Normal 54 Mixed Organised 54 Normal 63 Normal 64 Normal Organised 47 Medium 44 Press 54 Normal Cover