spider_version
int64
1
2
db_id
stringclasses
204 values
schema
stringclasses
187 values
question
stringlengths
3
328
query
stringlengths
20
3.81k
1
tracking_software_problems
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` ) )
Which problem log was created most recently? Give me the log id.
SELECT problem_log_id FROM problem_log ORDER BY log_entry_date DESC LIMIT 1
1
tracking_software_problems
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` ) )
What is the oldest log id and its corresponding problem id?
SELECT problem_log_id , problem_id FROM problem_log ORDER BY log_entry_date LIMIT 1
1
tracking_software_problems
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` ) )
Find the oldest log id and its corresponding problem id.
SELECT problem_log_id , problem_id FROM problem_log ORDER BY log_entry_date LIMIT 1
1
tracking_software_problems
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` ) )
Find all the ids and dates of the logs for the problem whose id is 10.
SELECT problem_log_id , log_entry_date FROM problem_log WHERE problem_id = 10
1
tracking_software_problems
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` ) )
For the problem with id 10, return the ids and dates of its problem logs.
SELECT problem_log_id , log_entry_date FROM problem_log WHERE problem_id = 10
1
tracking_software_problems
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` ) )
List all the log ids and their descriptions from the problem logs.
SELECT problem_log_id , log_entry_description FROM problem_log
1
tracking_software_problems
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` ) )
What are the log id and entry description of each problem?
SELECT problem_log_id , log_entry_description FROM problem_log
1
tracking_software_problems
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` ) )
List the first and last names of all distinct staff members who are assigned to the problem whose id is 1.
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
1
tracking_software_problems
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` ) )
Which staff members are assigned to the problem with id 1? Give me their first and last names.
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
1
tracking_software_problems
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` ) )
List the problem id and log id which are assigned to the staff named Rylan Homenick.
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"
1
tracking_software_problems
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` ) )
Which problem id and log id are assigned to the staff named Rylan Homenick?
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"
1
tracking_software_problems
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` ) )
How many problems are there for product voluptatem?
SELECT count(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"
1
tracking_software_problems
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` ) )
How many problems did the product called "voluptatem" have in record?
SELECT count(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"
1
tracking_software_problems
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` ) )
How many problems does the product with the most problems have? List the number of the problems and product name.
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
1
tracking_software_problems
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` ) )
Which product has the most problems? Give me the number of problems and the product name.
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
1
tracking_software_problems
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` ) )
Give me a list of descriptions of the problems that are reported by the staff whose first name is Christop.
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"
1
tracking_software_problems
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` ) )
Which problems are reported by the staff with first name "Christop"? Show the descriptions of the 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"
1
tracking_software_problems
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` ) )
Find the ids of the problems that are reported by the staff whose last name is Bosco.
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"
1
tracking_software_problems
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` ) )
Which problems are reported by the staff with last name "Bosco"? Show the ids of the 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"
1
tracking_software_problems
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` ) )
What are the ids of the problems which are reported after 1978-06-26?
SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"
1
tracking_software_problems
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` ) )
Find the ids of the problems reported after 1978-06-26.
SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"
1
tracking_software_problems
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` ) )
What are the ids of the problems which are reported before 1978-06-26?
SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"
1
tracking_software_problems
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` ) )
Which problems are reported before 1978-06-26? Give me the ids of the problems.
SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"
1
tracking_software_problems
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` ) )
For each product which has problems, what are the number of problems and the product id?
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
1
tracking_software_problems
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` ) )
For each product with some problems, list the count of problems and the product id.
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
1
tracking_software_problems
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` ) )
For each product that has problems, find the number of problems reported after 1986-11-13 and the product id?
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
1
tracking_software_problems
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` ) )
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.
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
1
tracking_software_problems
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` ) )
List the names of all the distinct product names in alphabetical order?
SELECT DISTINCT product_name FROM product ORDER BY product_name
1
tracking_software_problems
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` ) )
Sort all the distinct product names in alphabetical order.
SELECT DISTINCT product_name FROM product ORDER BY product_name
1
tracking_software_problems
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` ) )
List all the distinct product names ordered by product id?
SELECT DISTINCT product_name FROM product ORDER BY product_id
1
tracking_software_problems
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` ) )
What is the list of distinct product names sorted by product id?
SELECT DISTINCT product_name FROM product ORDER BY product_id
1
tracking_software_problems
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` ) )
What are the id of problems reported by the staff named Dameon Frami or Jolie Weber?
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"
1
tracking_software_problems
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` ) )
Which problems were reported by the staff named Dameon Frami or Jolie Weber? Give me the ids of the 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"
1
tracking_software_problems
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` ) )
What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?
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"
1
tracking_software_problems
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` ) )
For which product was there a problem reported by Christop Berge, with closure authorised by Ashley Medhurst? Return the product ids.
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"
1
tracking_software_problems
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` ) )
What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte?
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" )
1
tracking_software_problems
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` ) )
Which problems were reported before the date of any problem reported by the staff Lysanne Turcotte? Give me the ids of the 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" )
1
tracking_software_problems
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` ) )
What are the ids of the problems reported after the date of any problems reported by Rylan Homenick?
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" )
1
tracking_software_problems
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` ) )
Find the ids of the problems reported after the date of any problems reported by the staff Rylan Homenick.
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" )
1
tracking_software_problems
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` ) )
Find the top 3 products which have the largest number of 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
1
tracking_software_problems
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` ) )
What are the three products that have the most problems?s
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
1
tracking_software_problems
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` ) )
List the ids of the problems from the product "voluptatem" that are reported after 1995?
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"
1
tracking_software_problems
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` ) )
What are the ids of the problems that are from the product "voluptatem" and are reported after 1995?
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"
1
tracking_software_problems
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` ) )
Find the first and last name of the staff members who reported problems from the product "rem" but not "aut"?
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"
1
tracking_software_problems
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` ) )
Which staff members who reported problems from the product "rem" but not "aut"? Give me their first and last names.
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"
1
tracking_software_problems
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` ) )
Find the products which have problems reported by both Lacey Bosco and Kenton Champlin?
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"
1
tracking_software_problems
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` ) )
Which products have problems reported by both the staff named Lacey Bosco and the staff named Kenton Champlin?
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"
1
shop_membership
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") )
How many branches where have more than average number of memberships are there?
SELECT count(*) FROM branch WHERE membership_amount > (SELECT avg(membership_amount) FROM branch)
1
shop_membership
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") )
What is the number of branches that have more than the average number of memberships?
SELECT count(*) FROM branch WHERE membership_amount > (SELECT avg(membership_amount) FROM branch)
1
shop_membership
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") )
Show name, address road, and city for all branches sorted by open year.
SELECT name , address_road , city FROM branch ORDER BY open_year
1
shop_membership
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") )
What are the names, address roads, and cities of the branches ordered by opening year?
SELECT name , address_road , city FROM branch ORDER BY open_year
1
shop_membership
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") )
What are names for top three branches with most number of membership?
SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3
1
shop_membership
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") )
What are the names for the 3 branches that have the most memberships?
SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3
1
shop_membership
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") )
Show all distinct city where branches with at least 100 memberships are located.
SELECT DISTINCT city FROM branch WHERE membership_amount >= 100
1
shop_membership
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") )
What are the different cities that have more than 100 memberships?
SELECT DISTINCT city FROM branch WHERE membership_amount >= 100
1
shop_membership
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") )
List all open years when at least two shops are opened.
SELECT open_year FROM branch GROUP BY open_year HAVING count(*) >= 2
1
shop_membership
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") )
What are the opening years in which at least two shops opened?
SELECT open_year FROM branch GROUP BY open_year HAVING count(*) >= 2
1
shop_membership
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") )
Show minimum and maximum amount of memberships for all branches opened in 2011 or located at city London.
SELECT min(membership_amount) , max(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'
1
shop_membership
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") )
What are the minimum and maximum membership amounts for all branches that either opened in 2011 or are located in London?
SELECT min(membership_amount) , max(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'
1
shop_membership
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") )
Show the city and the number of branches opened before 2010 for each city.
SELECT city , count(*) FROM branch WHERE open_year < 2010 GROUP BY city
1
shop_membership
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") )
For each city, how many branches opened before 2010?
SELECT city , count(*) FROM branch WHERE open_year < 2010 GROUP BY city
1
shop_membership
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") )
How many different levels do members have?
SELECT count(DISTINCT LEVEL) FROM member
1
shop_membership
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") )
What are the different membership levels?
SELECT count(DISTINCT LEVEL) FROM member
1
shop_membership
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") )
Show card number, name, and hometown for all members in a descending order of level.
SELECT card_number , name , hometown FROM member ORDER BY LEVEL DESC
1
shop_membership
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") )
What are the card numbers, names, and hometowns of every member ordered by descending level?
SELECT card_number , name , hometown FROM member ORDER BY LEVEL DESC
1
shop_membership
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") )
Show the membership level with most number of members.
SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY count(*) DESC LIMIT 1
1
shop_membership
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") )
What is the membership level with the most people?
SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY count(*) DESC LIMIT 1
1
shop_membership
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") )
Show all member names and registered branch names sorted by register year.
SELECT T3.name , T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id ORDER BY T1.register_year
1
shop_membership
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") )
What are the names of the members and branches at which they are registered sorted by year of registration?
SELECT T3.name , T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id ORDER BY T1.register_year
1
shop_membership
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") )
Show all branch names with the number of members in each branch registered after 2015.
SELECT T2.name , count(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year > 2015 GROUP BY T2.branch_id
1
shop_membership
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") )
For each branch id, what are the names of the branches that were registered after 2015?
SELECT T2.name , count(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year > 2015 GROUP BY T2.branch_id
1
shop_membership
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") )
Show member names without any registered branch.
SELECT name FROM member WHERE member_id NOT IN (SELECT member_id FROM membership_register_branch)
1
shop_membership
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") )
What are the names of the members that have never registered at any branch?
SELECT name FROM member WHERE member_id NOT IN (SELECT member_id FROM membership_register_branch)
1
shop_membership
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") )
List the branch name and city without any registered members.
SELECT name , city FROM branch WHERE branch_id NOT IN (SELECT branch_id FROM membership_register_branch)
1
shop_membership
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") )
What are the names and cities of the branches that do not have any registered members?
SELECT name , city FROM branch WHERE branch_id NOT IN (SELECT branch_id FROM membership_register_branch)
1
shop_membership
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") )
What is the name and open year for the branch with most number of memberships registered in 2016?
SELECT T2.name , T2.open_year FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year = 2016 GROUP BY T2.branch_id ORDER BY count(*) DESC LIMIT 1
1
shop_membership
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") )
What is the name and opening year for the branch that registered the most members in 2016?
SELECT T2.name , T2.open_year FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year = 2016 GROUP BY T2.branch_id ORDER BY count(*) DESC LIMIT 1
1
shop_membership
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") )
Show the member name and hometown who registered a branch in 2016.
SELECT T2.name , T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016
1
shop_membership
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") )
What are the member names and hometowns of those who registered at a branch in 2016?
SELECT T2.name , T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016
1
shop_membership
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") )
Show all city with a branch opened in 2001 and a branch with more than 100 membership.
SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100
1
shop_membership
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") )
What are the cities that have a branch that opened in 2001 and a branch with more than 100 members?
SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100
1
shop_membership
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") )
Show all cities without a branch having more than 100 memberships.
SELECT city FROM branch EXCEPT SELECT city FROM branch WHERE membership_amount > 100
1
shop_membership
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") )
What are the cities that do not have any branches with more than 100 members?
SELECT city FROM branch EXCEPT SELECT city FROM branch WHERE membership_amount > 100
1
shop_membership
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") )
What is the sum of total pounds of purchase in year 2018 for all branches in London?
SELECT sum(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018
1
shop_membership
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") )
How many total pounds were purchased in the year 2018 at all London branches?
SELECT sum(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018
1
shop_membership
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") )
What is the total number of purchases for members with level 6?
SELECT count(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6
1
shop_membership
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") )
What are the total purchases for members rated at level 6?
SELECT count(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6
1
shop_membership
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") )
Find the name of branches where have some members whose hometown is in Louisville, Kentucky and some in Hiram, Georgia.
SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Louisville , Kentucky' INTERSECT SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Hiram , Georgia'
1
shop_membership
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") )
What are the names of the branches that have some members with a hometown in Louisville, Kentucky and also those from Hiram, Goergia?
SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Louisville , Kentucky' INTERSECT SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Hiram , Georgia'
1
shop_membership
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") )
list the card number of all members whose hometown address includes word "Kentucky".
SELECT card_number FROM member WHERE Hometown LIKE "%Kentucky%"
1
shop_membership
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") )
What are the card numbers of members from Kentucky?
SELECT card_number FROM member WHERE Hometown LIKE "%Kentucky%"
1
voter_2
Find the number of students in total.
SELECT count(*) FROM STUDENT
1
voter_2
How many students are there in total?
SELECT count(*) FROM STUDENT
1
voter_2
Find the number of voting records in total.
SELECT count(*) FROM VOTING_RECORD
1
voter_2
How many voting records do we have?
SELECT count(*) FROM VOTING_RECORD
1
voter_2
Find the distinct number of president votes.
SELECT count(DISTINCT President_Vote) FROM VOTING_RECORD
1
voter_2
How many distinct president votes are recorded?
SELECT count(DISTINCT President_Vote) FROM VOTING_RECORD
1
voter_2
Find the maximum age of all the students.
SELECT max(Age) FROM STUDENT
1
voter_2
What is the oldest age among the students?
SELECT max(Age) FROM STUDENT
1
voter_2
Find the last names of students with major 50.
SELECT LName FROM STUDENT WHERE Major = 50