db_id
stringclasses
127 values
query
stringlengths
20
523
question
stringlengths
16
224
schema
stringclasses
127 values
customers_and_addresses
SELECT count(*) FROM customer_orders WHERE order_details = "Second time"
Tell me the number of orders with "Second time" as order detail.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name , t2.order_date FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id WHERE order_status = "Delivered"
Find the customer name and date of the orders that have the status "Delivered".
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name , t2.order_date FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id WHERE order_status = "Delivered"
What are the customer name and date of the orders whose status is "Delivered".
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT sum(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_status = "Cancelled"
What is the total number of products that are in orders with status "Cancelled"?
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT sum(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_status = "Cancelled"
Find the total quantity of products associated with the orders in the "Cancelled" status.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT sum(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_date < "2018-03-17 07:13:53"
Find the total amount of products ordered before 2018-03-17 07:13:53.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT sum(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_date < "2018-03-17 07:13:53"
What is the total amount of products purchased before 2018-03-17 07:13:53?
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.order_date DESC LIMIT 1
Who made the latest order?
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.order_date DESC LIMIT 1
Find the name of the customer who made an order most recently.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t2.product_details FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY count(*) DESC LIMIT 1
Which product has been ordered most number of times?
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t2.product_details FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY count(*) DESC LIMIT 1
What is the most frequently ordered product? Tell me the detail of the product
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t2.product_details , t2.product_id FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY sum(t1.order_quantity) LIMIT 1
Find the name and ID of the product whose total order quantity is the largest.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t2.product_details , t2.product_id FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY sum(t1.order_quantity) LIMIT 1
What are the name and ID of the product bought the most.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT address_content FROM addresses WHERE city = "East Julianaside" AND state_province_county = "Texas" UNION SELECT address_content FROM addresses WHERE city = "Gleasonmouth" AND state_province_county = "Arizona"
Find all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT address_content FROM addresses WHERE city = "East Julianaside" AND state_province_county = "Texas" UNION SELECT address_content FROM addresses WHERE city = "Gleasonmouth" AND state_province_county = "Arizona"
What are all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method != 'Cash'
Find the name of customers who did not pay with Cash.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers WHERE payment_method != 'Cash'
What is the name of customers who do not use Cash as payment method.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte'
Find the names of customers who never ordered product Latte.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte'
What are names of customers who never ordered product Latte.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id
Find the names of customers who never placed an order.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id
What are the names of customers who never made an order.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte' INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Americano'
Find the names of customers who ordered both products Latte and Americano.
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
customers_and_addresses
SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte' INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Americano'
What are the names of customers who have purchased both products Latte and Americano?
CREATE TABLE `Addresses` ( `address_id` INTEGER PRIMARY KEY, `address_content` VARCHAR(80), `city` VARCHAR(50), `zip_postcode` VARCHAR(20), `state_province_county` VARCHAR(50), `country` VARCHAR(50), `other_address_details` VARCHAR(255) ); CREATE TABLE `Products` ( `product_id` INTEGER PRIMARY KEY, `product_details` VARCHAR(255) ); CREATE TABLE `Customers` ( `customer_id` INTEGER PRIMARY KEY, `payment_method` VARCHAR(15) NOT NULL, `customer_name` VARCHAR(80), `date_became_customer` DATETIME, `other_customer_details` VARCHAR(255) ); CREATE TABLE `Customer_Addresses` ( `customer_id` INTEGER NOT NULL, `address_id` INTEGER NOT NULL, `date_address_from` DATETIME NOT NULL, `address_type` VARCHAR(15) NOT NULL, `date_address_to` DATETIME, FOREIGN KEY (`address_id` ) REFERENCES `Addresses`(`address_id` ), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Contact_Channels` ( `customer_id` INTEGER NOT NULL, `channel_code` VARCHAR(15) NOT NULL, `active_from_date` DATETIME NOT NULL, `active_to_date` DATETIME, `contact_number` VARCHAR(50) NOT NULL, FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Customer_Orders` ( `order_id` INTEGER PRIMARY KEY, `customer_id` INTEGER NOT NULL, `order_status` VARCHAR(15) NOT NULL, `order_date` DATETIME, `order_details` VARCHAR(255), FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` ) ); CREATE TABLE `Order_Items` ( `order_id` INTEGER NOT NULL, `product_id` INTEGER NOT NULL, `order_quantity` VARCHAR(15), FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` ), FOREIGN KEY (`order_id` ) REFERENCES `Customer_Orders`(`order_id` ) ); INSERT INTO Addresses (`address_id`, `address_content`, `city`, `zip_postcode`, `state_province_county`, `country`, `other_address_details`) VALUES (1, '9443 Boyle Route Suite 857', 'Lucasville', '416', 'Colorado', 'USA', NULL); INSERT INTO Products (`product_id`, `product_details`) VALUES (1, 'Americano'); INSERT INTO Customers (`customer_id`, `payment_method`, `customer_name`, `date_became_customer`, `other_customer_details`) VALUES (1, 'Cash', 'Dr. Julia Wuckert MD', '2018-03-01 23:20:10', NULL); INSERT INTO Customer_Addresses (`customer_id`, `address_id`, `date_address_from`, `address_type`, `date_address_to`) VALUES (2, 11, '1985-03-29 20:31:43', 'Billing', '1993-02-17 17:55:18'); INSERT INTO Customer_Contact_Channels (`customer_id`, `channel_code`, `active_from_date`, `active_to_date`, `contact_number`) VALUES (9, 'Email', '2017-12-07 18:18:15', '2018-03-23 13:37:14', '940.035.6435x0225'); INSERT INTO Customer_Orders (`order_id`, `customer_id`, `order_status`, `order_date`, `order_details`) VALUES (1, 15, 'Cancelled', '2018-03-21 11:20:46', NULL); INSERT INTO Order_Items (`order_id`, `product_id`, `order_quantity`) VALUES (14, 2, '5');
music_4
SELECT count(*) FROM artist
How many artists are there?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT count(*) FROM artist
Count the number of artists.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Age FROM artist
List the age of all music artists.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Age FROM artist
What are the ages of all music artists?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT avg(Age) FROM artist
What is the average age of all artists?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT avg(Age) FROM artist
Return the average age across all artists.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title FROM artist WHERE Artist = "Triumfall"
What are the famous titles of the artist "Triumfall"?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title FROM artist WHERE Artist = "Triumfall"
Return the famous titles of the artist called "Triumfall".
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT distinct(Famous_Release_date) FROM artist
What are the distinct Famous release dates?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT distinct(Famous_Release_date) FROM artist
Give the distinct famous release dates for all artists.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Date_of_ceremony , RESULT FROM music_festival
Return the dates of ceremony and the results of all music festivals
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Date_of_ceremony , RESULT FROM music_festival
What are the dates of ceremony and results for each music festival?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category FROM music_festival WHERE RESULT = "Awarded"
What are the category of music festivals with result "Awarded"?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category FROM music_festival WHERE RESULT = "Awarded"
Return the categories of music festivals that have the result "Awarded".
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT max(Weeks_on_Top) , min(Weeks_on_Top) FROM volume
What are the maximum and minimum week on top of all volumes?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT max(Weeks_on_Top) , min(Weeks_on_Top) FROM volume
Give the maximum and minimum weeks on top across all volumes.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume WHERE Weeks_on_Top > 1
What are the songs in volumes with more than 1 week on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume WHERE Weeks_on_Top > 1
Give the songs included in volumes that have more than 1 week on top.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume ORDER BY Song
Please list all songs in volumes in ascending alphabetical order.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume ORDER BY Song
What are the the songs in volumes, listed in ascending order?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT COUNT(DISTINCT Artist_ID) FROM volume
How many distinct artists do the volumes associate to?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT COUNT(DISTINCT Artist_ID) FROM volume
Count the number of distinct artists who have volumes.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Date_of_ceremony FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T2.Weeks_on_Top > 2
Please show the date of ceremony of the volumes that last more than 2 weeks on top.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Date_of_ceremony FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T2.Weeks_on_Top > 2
What are the dates of ceremony at music festivals corresponding to volumes that lasted more than 2 weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Song FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T1.Result = "Nominated"
Please show the songs that have result "nominated" at music festivals.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Song FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T1.Result = "Nominated"
What are the songs in volumes that have resulted in a nomination at music festivals?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = "Gorgoroth"
What are the issue dates of volumes associated with the artist "Gorgoroth"?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = "Gorgoroth"
Return the issue dates of volumes that are by the artist named Gorgoroth.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Song FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age >= 32
What are the songs in volumes associated with the artist aged 32 or older?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T2.Song FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age >= 32
Return names of songs in volumes that are by artists that are at least 32 years old.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT avg(T2.Weeks_on_Top) FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 25
What is the average weeks on top of volumes associated with the artist aged 25 or younger?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT avg(T2.Weeks_on_Top) FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 25
Return the average number of weeks on top for volumes by artists that are at most 25 years old.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2
What are the famous title of the artists associated with volumes with more than 2 weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2
Return the famous titles for artists that have volumes that lasted more than 2 weeks on top.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title , Age FROM artist ORDER BY Age DESC
Please list the age and famous title of artists in descending order of age.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title , Age FROM artist ORDER BY Age DESC
What are the famous titles and ages of each artist, listed in descending order by age?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Release_date FROM artist ORDER BY Age DESC LIMIT 1
What is the famous release date of the artist with the oldest age?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Release_date FROM artist ORDER BY Age DESC LIMIT 1
Return the famous release date for the oldest artist.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category , COUNT(*) FROM music_festival GROUP BY Category
Please show the categories of the music festivals and the count.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category , COUNT(*) FROM music_festival GROUP BY Category
Return the number of music festivals of each category.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1
What is the most common result of the music festival?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1
Return the result that is most frequent at music festivals.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category FROM music_festival GROUP BY Category HAVING COUNT(*) > 1
Please show the categories of the music festivals with count more than 1.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Category FROM music_festival GROUP BY Category HAVING COUNT(*) > 1
What are the categories of music festivals for which there have been more than 1 music festival?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume ORDER BY Weeks_on_Top DESC LIMIT 1
What is the song in the volume with the maximum weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Song FROM volume ORDER BY Weeks_on_Top DESC LIMIT 1
Return the song in the volume that has spent the most weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title FROM artist WHERE Artist_ID NOT IN(SELECT Artist_ID FROM volume)
Find the famous titles of artists that do not have any volume.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Famous_Title FROM artist WHERE Artist_ID NOT IN(SELECT Artist_ID FROM volume)
What are the famous titles of artists who do not have any volumes?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2 INTERSECT SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top < 2
Show the famous titles of the artists with both volumes that lasted more than 2 weeks on top and volumes that lasted less than 2 weeks on top.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2 INTERSECT SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top < 2
What are the famous titles of artists who have not only had volumes that spent more than 2 weeks on top but also volumes that spent less than 2 weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Date_of_ceremony FROM music_festival WHERE Category = "Best Song" AND RESULT = "Awarded"
What are the date of ceremony of music festivals with category "Best Song" and result "Awarded"?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Date_of_ceremony FROM music_festival WHERE Category = "Best Song" AND RESULT = "Awarded"
Return the dates of ceremony corresponding to music festivals that had the category "Best Song" and result "Awarded".
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Issue_Date FROM volume ORDER BY Weeks_on_Top ASC LIMIT 1
What is the issue date of the volume with the minimum weeks on top?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Issue_Date FROM volume ORDER BY Weeks_on_Top ASC LIMIT 1
Return the issue date of the volume that has spent the fewest weeks on top.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT COUNT(DISTINCT Artist_ID) FROM volume
How many distinct artists have volumes?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT COUNT(DISTINCT Artist_ID) FROM volume
Count the number of artists who have had volumes.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT RESULT , COUNT(*) FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC
Please show the results of music festivals and the number of music festivals that have had each, ordered by this count.
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT RESULT , COUNT(*) FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC
How many music festivals have had each kind of result, ordered descending by count?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 23
What are the issue dates of volumes associated with the artist aged 23 or younger?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
music_4
SELECT Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 23
Return the issue dates of volumes by artists who are at most 23 years old?
CREATE TABLE "artist" ( "Artist_ID" int, "Artist" text, "Age" int, "Famous_Title" text, "Famous_Release_date" text, PRIMARY KEY ("Artist_ID") ); CREATE TABLE "volume" ( "Volume_ID" int, "Volume_Issue" text, "Issue_Date" text, "Weeks_on_Top" real, "Song" text, "Artist_ID" int, PRIMARY KEY ("Volume_ID"), FOREIGN KEY (`Artist_ID`) REFERENCES `artist`(`Artist_ID`) ); CREATE TABLE "music_festival" ( "ID" int, "Music_Festival" text, "Date_of_ceremony" text, "Category" text, "Volume" int, "Result" text, PRIMARY KEY (`ID`), FOREIGN KEY (`Volume`) REFERENCES `volume`(`Volume_ID`) ); INSERT INTO "artist" VALUES (1,"Gorgoroth",34,"Bergen 1996","November 2007"); INSERT INTO "volume" VALUES (1,"45:14 §","27 December 1986 - 10 January","3"," The Way",1); INSERT INTO "music_festival" VALUES (1,"34th England Academy Prize","18 February 2011","Best Song",1,"Nominated");
roller_coaster
SELECT count(*) FROM roller_coaster
How many roller coasters are there?
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Name FROM roller_coaster ORDER BY LENGTH ASC
List the names of roller coasters by ascending order of length.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT LENGTH , Height FROM roller_coaster
What are the lengths and heights of roller coasters?
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Name FROM country WHERE Languages != "German"
List the names of countries whose language is not "German".
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Status FROM roller_coaster WHERE LENGTH > 3300 OR Height > 100
Show the statuses of roller coasters longer than 3300 or higher than 100.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Speed FROM roller_coaster ORDER BY LENGTH DESC LIMIT 1
What are the speeds of the longest roller coaster?
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT avg(Speed) FROM roller_coaster
What is the average speed of roller coasters?
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Status , COUNT(*) FROM roller_coaster GROUP BY Status
Show the different statuses and the numbers of roller coasters for each status.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Status FROM roller_coaster GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
Please show the most common status of roller coasters.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Status FROM roller_coaster GROUP BY Status HAVING COUNT(*) > 2
List the status shared by more than two roller coaster.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT Park FROM roller_coaster ORDER BY Speed DESC LIMIT 1
Show the park of the roller coaster with the highest speed.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT T2.Name , T1.Name FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID
Show the names of roller coasters and names of country they are in.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT T1.Name FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID GROUP BY T1.Name HAVING COUNT(*) > 1
Show the names of countries that have more than one roller coaster.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT T1.Name , T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID ORDER BY T2.Height DESC LIMIT 1
Show the name and population of the country that has the highest roller coaster.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT T1.Name , avg(T2.Speed) FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID GROUP BY T1.Name
Show the names of countries and the average speed of roller coasters from each country.
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT count(*) FROM country WHERE country_id NOT IN ( SELECT country_id FROM roller_coaster WHERE LENGTH > 3000 )
How many countries do not have an roller coaster longer than 3000?
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");
roller_coaster
SELECT T1.name , T1.area , T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed > 60 INTERSECT SELECT T1.name , T1.area , T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed < 55
What are the country names, area and population which has both roller coasters with speed higher
CREATE TABLE "roller_coaster" ( "Roller_Coaster_ID" int, "Name" text, "Park" text, "Country_ID" int, "Length" real, "Height" real, "Speed" text, "Opened" text, "Status" text, PRIMARY KEY ("Roller_Coaster_ID"), FOREIGN KEY ("Country_ID") REFERENCES `country`("Country_ID") ); CREATE TABLE "country" ( "Country_ID" int, "Name" text, "Population" int, "Area" int, "Languages" text, PRIMARY KEY ("Country_ID") ); INSERT INTO "country" VALUES (1,"Austria","8206524","83871","German"); INSERT INTO "roller_coaster" VALUES (1,"Boardwalk Bullet","Kemah Boardwalk",1,"3236","96","51","August 31, 2007","Operating");