db_id
stringclasses
127 values
query
stringlengths
20
523
question
stringlengths
16
224
schema
stringclasses
127 values
manufactory_1
SELECT count(*) , T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name
Find the number of products for each manufacturer, showing the name of each company.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT count(*) , T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name
How many products are there for each manufacturer?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT Name FROM Products
Select the names of all the products in the store.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT Name FROM Products
What are the names of all products?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM products
Select the names and the prices of all the products in the store.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM products
What are the names and prices of all products in the store?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name FROM products WHERE price <= 200
Select the name of the products with a price less than or equal to $200.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name FROM products WHERE price <= 200
What are the names of products with price at most 200?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT * FROM products WHERE price BETWEEN 60 AND 120
Find all information of all the products with a price between $60 and $120.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT * FROM products WHERE price BETWEEN 60 AND 120
What is all the information of all the products that have a price between 60 and 120?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(price) FROM products
Compute the average price of all the products.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(price) FROM products
What is the average price across all products?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(price) FROM products WHERE Manufacturer = 2
Compute the average price of all products with manufacturer code equal to 2.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(price) FROM products WHERE Manufacturer = 2
What is the average price of products with manufacturer codes equal to 2?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT count(*) FROM products WHERE price >= 180
Compute the number of products with a price larger than or equal to $180.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT count(*) FROM products WHERE price >= 180
How many products have prices of at least 180?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM products WHERE price >= 180 ORDER BY price DESC , name ASC
Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order).
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM products WHERE price >= 180 ORDER BY price DESC , name ASC
What are the names and prices of products that cost at least 180, sorted by price decreasing and name ascending?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code
Select all the data from the products and each product's manufacturer.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code
What is all the product data, as well as each product's manufacturer?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT AVG(Price) , Manufacturer FROM Products GROUP BY Manufacturer
Select the average price of each manufacturer's products, showing only the manufacturer's code.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT AVG(Price) , Manufacturer FROM Products GROUP BY Manufacturer
What are the average prices of products, grouped by manufacturer code?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
Select the average price of each manufacturer's products, showing the manufacturer's name.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
What are the average prices of products, grouped by manufacturer name?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING avg(T1.price) >= 150
Select the names of manufacturer whose products have an average price higher than or equal to $150.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING avg(T1.price) >= 150
What are the names and average prices of products for manufacturers whose products cost on average 150 or more?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM Products ORDER BY price ASC LIMIT 1
Select the name and price of the cheapest product.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT name , price FROM Products ORDER BY price ASC LIMIT 1
What is the name and price of the cheapest product?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT T1.Name , max(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
Select the name of each manufacturer along with the name and price of its most expensive product.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT T1.Name , max(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
For each manufacturer name, what are the names and prices of their most expensive product?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT code , name , min(price) FROM products GROUP BY name
Select the code of the product that is cheapest in each product category.
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
manufactory_1
SELECT code , name , min(price) FROM products GROUP BY name
What are the codes and names of the cheapest products in each category?
-- LINK: https://en.wikibooks.org/wiki/SQL_Exercises/The_computer_store CREATE TABLE Manufacturers ( Code INTEGER, Name VARCHAR(255) NOT NULL, Headquarter VARCHAR(255) NOT NULL, Founder VARCHAR(255) NOT NULL, Revenue REAL, PRIMARY KEY (Code) ); CREATE TABLE Products ( Code INTEGER, Name VARCHAR(255) NOT NULL , Price DECIMAL NOT NULL , Manufacturer INTEGER NOT NULL, PRIMARY KEY (Code), FOREIGN KEY (Manufacturer) REFERENCES Manufacturers(Code) ); INSERT INTO Manufacturers VALUES(1,'Sony', 'Tokyo', 'Andy', 120); INSERT INTO Products(Code,Name,Price,Manufacturer) VALUES(1,'Hard drive',240,5)
tracking_software_problems
SELECT problem_log_id FROM problem_log ORDER BY log_entry_date DESC LIMIT 1
What is the id of the problem log that is created most recently?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id FROM problem_log ORDER BY log_entry_date DESC LIMIT 1
Which problem log was created most recently? Give me the log id.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , problem_id FROM problem_log ORDER BY log_entry_date LIMIT 1
What is the oldest log id and its corresponding problem id?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , problem_id FROM problem_log ORDER BY log_entry_date LIMIT 1
Find the oldest log id and its corresponding problem id.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , log_entry_date FROM problem_log WHERE problem_id = 10
Find all the ids and dates of the logs for the problem whose id is 10.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , log_entry_date FROM problem_log WHERE problem_id = 10
For the problem with id 10, return the ids and dates of its problem logs.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , log_entry_description FROM problem_log
List all the log ids and their descriptions from the problem logs.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_log_id , log_entry_description FROM problem_log
What are the log id and entry description of each problem?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT staff_first_name , staff_last_name FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T2.problem_id = 1
List the first and last names of all distinct staff members who are assigned to the problem whose id is 1.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT staff_first_name , staff_last_name FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T2.problem_id = 1
Which staff members are assigned to the problem with id 1? Give me their first and last names.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT T2.problem_id , T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = "Rylan" AND T1.staff_last_name = "Homenick"
List the problem id and log id which are assigned to the staff named Rylan Homenick.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT T2.problem_id , T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = "Rylan" AND T1.staff_last_name = "Homenick"
Which problem id and log id are assigned to the staff named Rylan Homenick?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"
How many problems are there for product voluptatem?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"
How many problems did the product called "voluptatem" have in record?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY count(*) DESC LIMIT 1
How many problems does the product with the most problems have? List the number of the problems and product name.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY count(*) DESC LIMIT 1
Which product has the most problems? Give me the number of problems and the product name.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_description FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop"
Give me a list of descriptions of the problems that are reported by the staff whose first name is Christop.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_description FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop"
Which problems are reported by the staff with first name "Christop"? Show the descriptions of the problems.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_last_name = "Bosco"
Find the ids of the problems that are reported by the staff whose last name is Bosco.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_last_name = "Bosco"
Which problems are reported by the staff with last name "Bosco"? Show the ids of the problems.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"
What are the ids of the problems which are reported after 1978-06-26?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"
Find the ids of the problems reported after 1978-06-26.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"
What are the ids of the problems which are reported before 1978-06-26?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"
Which problems are reported before 1978-06-26? Give me the ids of the problems.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_id
For each product which has problems, what are the number of problems and the product id?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_id
For each product with some problems, list the count of problems and the product id.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > "1986-11-13" GROUP BY T2.product_id
For each product that has problems, find the number of problems reported after 1986-11-13 and the product id?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT count(*) , T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > "1986-11-13" GROUP BY T2.product_id
What are the products that have problems reported after 1986-11-13? Give me the product id and the count of problems reported after 1986-11-13.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT product_name FROM product ORDER BY product_name
List the names of all the distinct product names in alphabetical order?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT product_name FROM product ORDER BY product_name
Sort all the distinct product names in alphabetical order.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT product_name FROM product ORDER BY product_id
List all the distinct product names ordered by product id?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT DISTINCT product_name FROM product ORDER BY product_id
What is the list of distinct product names sorted by product id?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_last_name = "Weber"
What are the id of problems reported by the staff named Dameon Frami or Jolie Weber?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_last_name = "Weber"
Which problems were reported by the staff named Dameon Frami or Jolie Weber? Give me the ids of the problems.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst"
What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst"
For which product was there a problem reported by Christop Berge, with closure authorised by Ashley Medhurst? Return the product ids.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < ( SELECT min(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte" )
What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < ( SELECT min(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte" )
Which problems were reported before the date of any problem reported by the staff Lysanne Turcotte? Give me the ids of the problems.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported > ( SELECT max(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Rylan" AND T4.staff_last_name = "Homenick" )
What are the ids of the problems reported after the date of any problems reported by Rylan Homenick?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported > ( SELECT max(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Rylan" AND T4.staff_last_name = "Homenick" )
Find the ids of the problems reported after the date of any problems reported by the staff Rylan Homenick.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY count(*) DESC LIMIT 3
Find the top 3 products which have the largest number of problems?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY count(*) DESC LIMIT 3
What are the three products that have the most problems?s
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T2.product_name = "voluptatem" AND T1.date_problem_reported > "1995"
List the ids of the problems from the product "voluptatem" that are reported after 1995?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T1.problem_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T2.product_name = "voluptatem" AND T1.date_problem_reported > "1995"
What are the ids of the problems that are from the product "voluptatem" and are reported after 1995?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T3.staff_first_name , T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "rem" EXCEPT SELECT T3.staff_first_name , T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "aut"
Find the first and last name of the staff members who reported problems from the product "rem" but not "aut"?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T3.staff_first_name , T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "rem" EXCEPT SELECT T3.staff_first_name , T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "aut"
Which staff members who reported problems from the product "rem" but not "aut"? Give me their first and last names.
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin"
Find the products which have problems reported by both Lacey Bosco and Kenton Champlin?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
tracking_software_problems
SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin"
Which products have problems reported by both the staff named Lacey Bosco and the staff named Kenton Champlin?
PRAGMA foreign_keys = ON; CREATE TABLE `Problem_Category_Codes` ( `problem_category_code` VARCHAR(20) PRIMARY KEY, `problem_category_description` VARCHAR(80) ); CREATE TABLE `Problem_Log` ( `problem_log_id` INTEGER PRIMARY KEY, `assigned_to_staff_id` INTEGER NOT NULL, `problem_id` INTEGER NOT NULL, `problem_category_code` VARCHAR(20) NOT NULL, `problem_status_code` VARCHAR(20) NOT NULL, `log_entry_date` DATETIME, `log_entry_description` VARCHAR(255), `log_entry_fix` VARCHAR(255), `other_log_details` VARCHAR(255), FOREIGN KEY (`problem_category_code` ) REFERENCES `Problem_Category_Codes`(`problem_category_code` ),FOREIGN KEY (`assigned_to_staff_id` ) REFERENCES `Staff`(`staff_id` ),FOREIGN KEY (`problem_id` ) REFERENCES `Problems`(`problem_id` ),FOREIGN KEY (`problem_status_code` ) REFERENCES `Problem_Status_Codes`(`problem_status_code` ) ); CREATE TABLE `Problem_Status_Codes` ( `problem_status_code` VARCHAR(20) PRIMARY KEY, `problem_status_description` VARCHAR(80) ); CREATE TABLE `Product` ( `product_id` INTEGER PRIMARY KEY, `product_name` VARCHAR(80), `product_details` VARCHAR(255) ); CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `staff_first_name` VARCHAR(80), `staff_last_name` VARCHAR(80), `other_staff_details` VARCHAR(255) ); CREATE TABLE `Problems` ( `problem_id` INTEGER PRIMARY KEY, `product_id` INTEGER NOT NULL, `closure_authorised_by_staff_id` INTEGER NOT NULL, `reported_by_staff_id` INTEGER NOT NULL, `date_problem_reported` DATETIME NOT NULL, `date_problem_closed` DATETIME, `problem_description` VARCHAR(255), `other_problem_details` VARCHAR(255), FOREIGN KEY (`closure_authorised_by_staff_id` ) REFERENCES `Staff`(`staff_id` ), FOREIGN KEY (`product_id` ) REFERENCES `Product`(`product_id` ), FOREIGN KEY (`reported_by_staff_id` ) REFERENCES `Staff`(`staff_id` ) ); INSERT INTO `Problem_Category_Codes` (`problem_category_code`, `problem_category_description`) VALUES ('Datatabase', 'Database design or contents.')INSERT INTO `Problem_Status_Codes` (`problem_status_code`, `problem_status_description`) VALUES ('Reported', 'Reported')INSERT INTO Staff (`staff_id`, `staff_first_name`, `staff_last_name`, `other_staff_details`) VALUES (1, 'Lacey', 'Bosco', 'm')INSERT INTO Product (`product_id`, `product_name`, `product_details`) VALUES (1, 'rose', 'k')INSERT INTO Problems (`problem_id`, `product_id`, `closure_authorised_by_staff_id`, `reported_by_staff_id`, `date_problem_reported`, `date_problem_closed`, `problem_description`, `other_problem_details`) VALUES (1, 4, 4, 2, '1978-06-26 19:10:17', '2012-07-22 19:24:26', 'x', 'p')INSERT INTO Problem_Log (`problem_log_id`, `assigned_to_staff_id`, `problem_id`, `problem_category_code`, `problem_status_code`, `log_entry_date`, `log_entry_description`, `log_entry_fix`, `other_log_details`) VALUES (1, 11, 11, 'Middleware', 'Solved', '2011-03-13 13:11:57', 't', 'k', 'p')
shop_membership
SELECT count(*) FROM branch WHERE membership_amount > (SELECT avg(membership_amount) FROM branch)
How many branches where have more than average number of memberships are there?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT count(*) FROM branch WHERE membership_amount > (SELECT avg(membership_amount) FROM branch)
What is the number of branches that have more than the average number of memberships?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT name , address_road , city FROM branch ORDER BY open_year
Show name, address road, and city for all branches sorted by open year.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT name , address_road , city FROM branch ORDER BY open_year
What are the names, address roads, and cities of the branches ordered by opening year?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3
What are names for top three branches with most number of membership?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3
What are the names for the 3 branches that have the most memberships?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT DISTINCT city FROM branch WHERE membership_amount >= 100
Show all distinct city where branches with at least 100 memberships are located.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT DISTINCT city FROM branch WHERE membership_amount >= 100
What are the different cities that have more than 100 memberships?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT open_year FROM branch GROUP BY open_year HAVING count(*) >= 2
List all open years when at least two shops are opened.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT open_year FROM branch GROUP BY open_year HAVING count(*) >= 2
What are the opening years in which at least two shops opened?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT min(membership_amount) , max(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'
Show minimum and maximum amount of memberships for all branches opened in 2011 or located at city London.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT min(membership_amount) , max(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'
What are the minimum and maximum membership amounts for all branches that either opened in 2011 or are located in London?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT city , count(*) FROM branch WHERE open_year < 2010 GROUP BY city
Show the city and the number of branches opened before 2010 for each city.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT city , count(*) FROM branch WHERE open_year < 2010 GROUP BY city
For each city, how many branches opened before 2010?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT count(DISTINCT LEVEL) FROM member
How many different levels do members have?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT count(DISTINCT LEVEL) FROM member
What are the different membership levels?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT card_number , name , hometown FROM member ORDER BY LEVEL DESC
Show card number, name, and hometown for all members in a descending order of level.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT card_number , name , hometown FROM member ORDER BY LEVEL DESC
What are the card numbers, names, and hometowns of every member ordered by descending level?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY count(*) DESC LIMIT 1
Show the membership level with most number of members.
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);
shop_membership
SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY count(*) DESC LIMIT 1
What is the membership level with the most people?
PRAGMA foreign_keys = ON; CREATE TABLE "member" ( "Member_ID" int, "Card_Number" text, "Name" text, "Hometown" text, "Level" int, PRIMARY KEY ("Member_ID") ); CREATE TABLE "branch" ( "Branch_ID" int, "Name" text, "Open_year" text, "Address_road" text, "City" text, "membership_amount" text, PRIMARY KEY ("Branch_ID") ); CREATE TABLE "membership_register_branch" ( "Member_ID" int, "Branch_ID" text, "Register_Year" text, PRIMARY KEY ("Member_ID"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); CREATE TABLE "purchase" ( "Member_ID" int, "Branch_ID" text, "Year" text, "Total_pounds" real, PRIMARY KEY ("Member_ID","Branch_ID","Year"), FOREIGN KEY ("Member_ID") REFERENCES "member"("Member_ID"), FOREIGN KEY ("Branch_ID") REFERENCES "branch"("Branch_ID") ); INSERT INTO "member" VALUES (1,"LE99","Jeremy Jarmon","Collierville, Tennessee","6"); INSERT INTO "branch" VALUES (1,"Alexandre","2001","Valleys Place","London","112"); INSERT INTO "membership_register_branch" VALUES (1,1,"2016"); INSERT INTO "purchase" VALUES (1,3,"2018",2013.32);