db_id
stringclasses
146 values
question
stringlengths
3
224
sql
stringlengths
18
577
database_schema
stringclasses
146 values
customer_complaints
How many customers are there in the customer type with the most customers?
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Count the number of customers that have the customer type that is most common.
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
What is the last name of the staff who has handled the first ever complaint?
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Return the last name of the staff member who handled the complaint with the earliest date raised.
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
How many distinct complaint type codes are there in the database?
SELECT count(DISTINCT complaint_type_code) FROM complaints
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Count the number of different complaint type codes.
SELECT count(DISTINCT complaint_type_code) FROM complaints
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Find the address line 1 and 2 of the customer with email "vbogisich@example.org".
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
What are lines 1 and 2 of the addressed of the customer with the email "vbogisich@example.org"?
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Find the number of complaints with Product Failure type for each complaint status.
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Of complaints with the type code "Product Failure", how many had each different status code?
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
What is first names of the top 5 staff who have handled the greatest number of complaints?
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Return the first names of the 5 staff members who have handled the most complaints.
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Which state has the most customers?
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
customer_complaints
Give the state that has the most customers.
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Staff table: staff_id gender first_name last_name email_address phone_number 114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146 115 1 Lucie Lowe ohintz@example.org 142-311-6503x206 116 0 Dagmar Erdman wrau@example.com 345-656-5571 CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `customer_type_code` VARCHAR(20) NOT NULL, `address_line_1` VARCHAR(80), `address_line_2` VARCHAR(80), `town_city` VARCHAR(80), `state` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ) 3 rows from Customers table: customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number 113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450 114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244 115 Good Credit Rating 92189 Gulgowski Ranch Apt. 683 Apt. 828 Tyreekhaven Tennessee vida86@example.com 997.698.4779x882 CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `parent_product_id` INTEGER, `product_category_code` VARCHAR(20) NOT NULL, `date_product_first_available` DATETIME, `date_product_discontinued` DATETIME, `product_name` VARCHAR(80), `product_description` VARCHAR(255), `product_price` DECIMAL(19,4) ) 3 rows from Products table: product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price 117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.88 118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.00 119 8 Hardware 1994-12-18 15:13:19 1997-07-02 18:26:16 Keyboard Designed for games 109.99 CREATE TABLE `Complaints` ( `complaint_id` INTEGER NOT NULL , `product_id` INTEGER NOT NULL, `customer_id` INTEGER NOT NULL, `complaint_outcome_code` VARCHAR(20) NOT NULL, `complaint_status_code` VARCHAR(20) NOT NULL, `complaint_type_code` VARCHAR(20) NOT NULL, `date_complaint_raised` DATETIME, `date_complaint_closed` DATETIME, `staff_id` INTEGER NOT NULL , FOREIGN KEY (`staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ) 3 rows from Complaints table: complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id 1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114 2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120 3 119 114 OK New Product Unusable 2006-10-29 07:08:46 1995-09-11 14:48:46 115
workshop_paper
How many submissions are there?
SELECT count(*) FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Count the number of submissions.
SELECT count(*) FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
List the authors of submissions in ascending order of scores.
SELECT Author FROM submission ORDER BY Scores ASC
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Find the author for each submission and list them in ascending order of submission score.
SELECT Author FROM submission ORDER BY Scores ASC
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
What are the authors of submissions and their colleges?
SELECT Author , College FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
For each submission, show the author and their affiliated college.
SELECT Author , College FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the names of authors from college "Florida" or "Temple"
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which authors with submissions are from college "Florida" or "Temple"?
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
What is the average score of submissions?
SELECT avg(Scores) FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Compute the average score of submissions.
SELECT avg(Scores) FROM submission
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
What is the author of the submission with the highest score?
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Find the author who achieved the highest score in a submission.
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show different colleges along with the number of authors of submission from each college.
SELECT College , COUNT(*) FROM submission GROUP BY College
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
For each college, return the college name and the count of authors with submissions from that college.
SELECT College , COUNT(*) FROM submission GROUP BY College
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the most common college of authors of submissions.
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which college has the most authors with submissions?
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the colleges that have both authors with submission score larger than 90 and authors with submission score smaller than 80.
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which colleges have both authors with submission score above 90 and authors with submission score below 80?
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the authors of submissions and the acceptance results of their submissions.
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
For each submission, find its author and acceptance result.
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the result of the submission with the highest score.
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which submission received the highest score in acceptance result. Show me the result.
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show each author and the number of workshops they submitted to.
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
How many workshops did each author submit to? Return the author name and the number of workshops.
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the authors who have submissions to more than one workshop.
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which authors have submitted to more than one workshop?
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Show the date and venue of each workshop in ascending alphabetical order of the venue.
SELECT Date , Venue FROM workshop ORDER BY Venue
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Sort the each workshop in alphabetical order of the venue. Return the date and venue of each workshop.
SELECT Date , Venue FROM workshop ORDER BY Venue
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
List the authors who do not have submission to any workshop.
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
workshop_paper
Which authors did not submit to any workshop?
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ) 3 rows from workshop table: Workshop_ID Date Venue Name 1 August 18, 2007 London UK ABC 2007 2 August 21, 2007 London UK Conference 2007 3 August 25, 2007 New Jersey USA Workshop 2007 CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ) 3 rows from submission table: Submission_ID Scores Author College 1 72.0 Steve Niehaus Notre Dame 2 79.0 Sammy Green Florida 3 78.0 Sherman Smith Miami (OH) CREATE TABLE "Acceptance" ( "Submission_ID" int, "Workshop_ID" int, "Result" text, PRIMARY KEY ("Submission_ID","Workshop_ID"), FOREIGN KEY ("Submission_ID") REFERENCES `submission`("Submission_ID"), FOREIGN KEY ("Workshop_ID") REFERENCES `workshop`("Workshop_ID") ) 3 rows from Acceptance table: Submission_ID Workshop_ID Result 2 5 Accepted 2 3 Rejected 3 2 Rejected
tracking_share_transactions
Find the number of investors in total.
SELECT count(*) FROM INVESTORS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show all investor details.
SELECT Investor_details FROM INVESTORS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show all distinct lot details.
SELECT DISTINCT lot_details FROM LOTS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the maximum amount of transaction.
SELECT max(amount_of_transaction) FROM TRANSACTIONS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show all date and share count of transactions.
SELECT date_of_transaction , share_count FROM TRANSACTIONS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What is the total share of transactions?
SELECT sum(share_count) FROM TRANSACTIONS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show all transaction ids with transaction code 'PUR'.
SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR'
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show all dates of transactions whose type code is "SALE".
SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average amount of transactions with type code "SALE".
SELECT avg(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the description of transaction type with code "PUR".
SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR"
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50.
SELECT min(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the maximum share count of transactions where the amount is smaller than 10000
SELECT max(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000.
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the transaction type descriptions and dates if the share count is smaller than 10.
SELECT T1.transaction_type_description , T2.date_of_transaction FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show details of all investors if they make any transaction with share count greater than 100.
SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
How many distinct transaction types are used in the transactions?
SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Return the lot details and investor ids.
SELECT lot_details , investor_id FROM LOTS
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Return the lot details of lots that belong to investors with details "l"?
SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l"
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the purchase details of transactions with amount bigger than 10000?
SELECT T1.purchase_details FROM PURCHASES AS T1 JOIN TRANSACTIONS AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the sale details and dates of transactions with amount smaller than 3000?
SELECT T1.sales_details , T2.date_of_transaction FROM SALES AS T1 JOIN TRANSACTIONS AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the lot details of lots associated with transactions with share count smaller than 50?
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count < 50
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the lot details of lots associated with transactions whose share count is bigger than 100 and whose type code is "PUR"?
SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count > 100 AND T3.transaction_type_code = "PUR"
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average transaction amount for different transaction types.
SELECT transaction_type_code , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY transaction_type_code
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the maximum and minimum share count of different transaction types.
SELECT transaction_type_code , max(share_count) , min(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average share count of transactions for different investors.
SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average share count of transactions each each investor, ordered by average share count.
SELECT investor_id , avg(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY avg(share_count)
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average amount of transactions for different investors.
SELECT investor_id , avg(amount_of_transaction) FROM TRANSACTIONS GROUP BY investor_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average amount of transactions for different lots.
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the average amount of transactions for different lots, ordered by average amount of transactions.
SELECT T2.lot_id , avg(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id ORDER BY avg(amount_of_transaction)
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the number of transactions with transaction type code "SALE" for different investors if it is larger than 0.
SELECT investor_id , COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the number of transactions for different investors.
SELECT investor_id , COUNT(*) FROM TRANSACTIONS GROUP BY investor_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the transaction type code that occurs the fewest times.
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) ASC LIMIT 1
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the transaction type code that occurs the most frequently.
SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the description of the transaction type that occurs most frequently.
SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the id and details of the investor that has the largest number of transactions.
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the id and details for the investors who have the top 3 number of transactions.
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the ids of the investors who have at least two transactions.
SELECT T2.investor_id FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id HAVING COUNT(*) >= 2
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
Show the ids and details of the investors who have at least two transactions with type code "SALE".
SELECT T2.investor_id , T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the dates of transactions with at least 100 share count or amount bigger than 100?
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the details of all sales and purchases?
SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
tracking_share_transactions
What are the details of the lots which are not used in any transactions?
SELECT lot_details FROM Lots EXCEPT SELECT T1.lot_details FROM Lots AS T1 JOIN transactions_lots AS T2 ON T1.lot_id = T2.lot_id
CREATE TABLE `Investors` ( `investor_id` INTEGER PRIMARY KEY, `Investor_details` VARCHAR(255) ) 3 rows from Investors table: investor_id Investor_details 1 z 2 z 3 d CREATE TABLE `Lots` ( `lot_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `lot_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ) ) 3 rows from Lots table: lot_id investor_id lot_details 1 13 r 2 16 z 3 10 s CREATE TABLE `Ref_Transaction_Types` ( `transaction_type_code` VARCHAR(10) PRIMARY KEY, `transaction_type_description` VARCHAR(80) NOT NULL ) 3 rows from Ref_Transaction_Types table: transaction_type_code transaction_type_description SALE Sale PUR Purchase CREATE TABLE `Transactions` ( `transaction_id` INTEGER PRIMARY KEY, `investor_id` INTEGER NOT NULL, `transaction_type_code` VARCHAR(10) NOT NULL, `date_of_transaction` DATETIME, `amount_of_transaction` DECIMAL(19,4), `share_count` VARCHAR(40), `other_details` VARCHAR(255), FOREIGN KEY (`investor_id` ) REFERENCES `Investors`(`investor_id` ),FOREIGN KEY (`transaction_type_code` ) REFERENCES `Ref_Transaction_Types`(`transaction_type_code` ) ) 3 rows from Transactions table: transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details 1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None 2 18 PUR 1982-06-06 17:19:00 27.2570 9 None 3 2 SALE 1979-04-27 06:03:59 48777.9690 8580 None CREATE TABLE `Sales` ( `sales_transaction_id` INTEGER PRIMARY KEY, `sales_details` VARCHAR(255), FOREIGN KEY (`sales_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Sales table: sales_transaction_id sales_details 1 x 2 o 3 a CREATE TABLE `Purchases` ( `purchase_transaction_id` INTEGER NOT NULL, `purchase_details` VARCHAR(255) NOT NULL, FOREIGN KEY (`purchase_transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Purchases table: purchase_transaction_id purchase_details 1 c 2 y 3 i CREATE TABLE `Transactions_Lots` ( `transaction_id` INTEGER NOT NULL, `lot_id` INTEGER NOT NULL, FOREIGN KEY (`lot_id` ) REFERENCES `Lots`(`lot_id` ), FOREIGN KEY (`transaction_id` ) REFERENCES `Transactions`(`transaction_id` ) ) 3 rows from Transactions_Lots table: transaction_id lot_id 3 11 3 8 2 11
cre_Theme_park
How many available hotels are there in total?
SELECT count(*) FROM HOTELS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Find the total number of available hotels.
SELECT count(*) FROM HOTELS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What are the price ranges of hotels?
SELECT price_range FROM HOTELS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Tell me the price ranges for all the hotels.
SELECT price_range FROM HOTELS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Show all distinct location names.
SELECT DISTINCT Location_Name FROM LOCATIONS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What are the distinct location names?
SELECT DISTINCT Location_Name FROM LOCATIONS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Show the names and details of all the staff members.
SELECT Name , Other_Details FROM Staff
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What is the name and detail of each staff member?
SELECT Name , Other_Details FROM Staff
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Show details of all visitors.
SELECT Tourist_Details FROM VISITORS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What is the detail of each visitor?
SELECT Tourist_Details FROM VISITORS
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Show the price ranges of hotels with 5 star ratings.
SELECT price_range FROM HOTELS WHERE star_rating_code = "5"
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What are the price ranges of five star hotels?
SELECT price_range FROM HOTELS WHERE star_rating_code = "5"
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
Show the average price range of hotels that have 5 star ratings and allow pets.
SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What is the average price range of five star hotels that allow pets?
SELECT avg(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523
cre_Theme_park
What is the address of the location "UK Gallery"?
SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery"
CREATE TABLE Ref_Hotel_Star_Ratings ( star_rating_code CHAR(15) NOT NULL, star_rating_description VARCHAR(80), PRIMARY KEY (star_rating_code), UNIQUE (star_rating_code) ) 3 rows from Ref_Hotel_Star_Ratings table: star_rating_code star_rating_description 1 star 2 star 3 star CREATE TABLE Locations ( Location_ID INTEGER NOT NULL, Location_Name VARCHAR(255), Address VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Location_ID) ) 3 rows from Locations table: Location_ID Location_Name Address Other_Details 333 Astro Orbiter 660 Shea Crescent None 368 African Animals 254 Ottilie Junction None 417 American Adventure 53815 Sawayn Tunnel Apt. 297 None CREATE TABLE Ref_Attraction_Types ( Attraction_Type_Code CHAR(15) NOT NULL, Attraction_Type_Description VARCHAR(255), PRIMARY KEY (Attraction_Type_Code), UNIQUE (Attraction_Type_Code) ) 3 rows from Ref_Attraction_Types table: Attraction_Type_Code Attraction_Type_Description 2 park 3 garden 5 gallery CREATE TABLE Visitors ( Tourist_ID INTEGER NOT NULL, Tourist_Details VARCHAR(255), PRIMARY KEY (Tourist_ID), UNIQUE (Tourist_ID) ) 3 rows from Visitors table: Tourist_ID Tourist_Details 164 Toney 189 Graciela 204 Vincent CREATE TABLE Features ( Feature_ID INTEGER NOT NULL, Feature_Details VARCHAR(255), PRIMARY KEY (Feature_ID) ) 3 rows from Features table: Feature_ID Feature_Details 523 cafe 528 park 543 garden CREATE TABLE Hotels ( hotel_id INTEGER NOT NULL, star_rating_code CHAR(15) NOT NULL, pets_allowed_yn CHAR(1), price_range real, other_hotel_details VARCHAR(255), PRIMARY KEY (hotel_id), FOREIGN KEY (star_rating_code) REFERENCES Ref_Hotel_Star_Ratings (star_rating_code) ) 3 rows from Hotels table: hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details 123 5 1 2914989.571 None 144 4 None 172 5 17012.682586 None CREATE TABLE Tourist_Attractions ( Tourist_Attraction_ID INTEGER NOT NULL, Attraction_Type_Code CHAR(15) NOT NULL, Location_ID INTEGER NOT NULL, How_to_Get_There VARCHAR(255), Name VARCHAR(255), Description VARCHAR(255), Opening_Hours VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Tourist_Attraction_ID), FOREIGN KEY (Location_ID) REFERENCES Locations (Location_ID), FOREIGN KEY (Attraction_Type_Code) REFERENCES Ref_Attraction_Types (Attraction_Type_Code) ) 3 rows from Tourist_Attractions table: Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details 2113 2 579 bus art museum None None None 2701 6 417 walk UK gallery None None None 5076 2 868 shuttle flying elephant None None None CREATE TABLE Street_Markets ( Market_ID INTEGER NOT NULL, Market_Details VARCHAR(255), PRIMARY KEY (Market_ID), FOREIGN KEY (Market_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Street_Markets table: Market_ID Market_Details 6852 Broadway 7067 Fish Farm Market CREATE TABLE Shops ( Shop_ID INTEGER NOT NULL, Shop_Details VARCHAR(255), PRIMARY KEY (Shop_ID), FOREIGN KEY (Shop_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Shops table: Shop_ID Shop_Details 8429 soup 8449 coffee 8698 Flower CREATE TABLE Museums ( Museum_ID INTEGER NOT NULL, Museum_Details VARCHAR(255), PRIMARY KEY (Museum_ID), FOREIGN KEY (Museum_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Museums table: Museum_ID Museum_Details 2113 Yale Center for British Art 2701 The Metropolitan Museum of Art 5076 MoMA CREATE TABLE Royal_Family ( Royal_Family_ID INTEGER NOT NULL, Royal_Family_Details VARCHAR(255), PRIMARY KEY (Royal_Family_ID), FOREIGN KEY (Royal_Family_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Royal_Family table: Royal_Family_ID Royal_Family_Details 9561 None 9919 None CREATE TABLE Theme_Parks ( Theme_Park_ID INTEGER NOT NULL, Theme_Park_Details VARCHAR(255), PRIMARY KEY (Theme_Park_ID), FOREIGN KEY (Theme_Park_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Theme_Parks table: Theme_Park_ID Theme_Park_Details 5265 Disney 6476 Sea World 6523 Universal Studios CREATE TABLE Visits ( Visit_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Tourist_ID INTEGER NOT NULL, Visit_Date DATETIME NOT NULL, Visit_Details VARCHAR(40) NOT NULL, PRIMARY KEY (Visit_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Tourist_ID) REFERENCES Visitors (Tourist_ID) ) 3 rows from Visits table: Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details 183 6653 377 2004-08-21 03:06:14 268 5076 204 2013-08-06 05:35:51 273 9360 211 2013-10-27 09:56:08 CREATE TABLE Photos ( Photo_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(255), Description VARCHAR(255), Filename VARCHAR(255), Other_Details VARCHAR(255), PRIMARY KEY (Photo_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Photos table: Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details 211 8449 game1 None 702 None 280 7067 game2 None 762 None 303 5076 game3 None 392 None CREATE TABLE Staff ( Staff_ID INTEGER NOT NULL, Tourist_Attraction_ID INTEGER NOT NULL, Name VARCHAR(40), Other_Details VARCHAR(255), PRIMARY KEY (Staff_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID) ) 3 rows from Staff table: Staff_ID Tourist_Attraction_ID Name Other_Details 170 6476 Whitney None 219 6476 Kaela None 237 7067 Eunice None CREATE TABLE Tourist_Attraction_Features ( Tourist_Attraction_ID INTEGER NOT NULL, Feature_ID INTEGER NOT NULL, PRIMARY KEY (Tourist_Attraction_ID, Feature_ID), FOREIGN KEY (Tourist_Attraction_ID) REFERENCES Tourist_Attractions (Tourist_Attraction_ID), FOREIGN KEY (Feature_ID) REFERENCES Features (Feature_ID) ) 3 rows from Tourist_Attraction_Features table: Tourist_Attraction_ID Feature_ID 5076 528 5076 681 5265 523