question
stringlengths
16
224
schema
stringlengths
142
5.86k
query
stringlengths
20
577
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
Student: StuID (INTEGER), LName (VARCHAR(12)), Fname (VARCHAR(12)), Age (INTEGER), Sex (VARCHAR(1)), Major (INTEGER), Advisor (INTEGER), city_code (VARCHAR(3)) Dorm: dormid (INTEGER), dorm_name (VARCHAR(20)), student_capacity (INTEGER), gender (VARCHAR(1)) Dorm_amenity: amenid (INTEGER), amenity_name (VARCHAR(25)) Has_amenity: dormid (INTEGER), amenid (INTEGER) Lives_in: stuid (INTEGER), dormid (INTEGER), room_number (INTEGER)
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
What is the first name and age of every student who lives in a dorm with a TV Lounge?
Student: StuID (INTEGER), LName (VARCHAR(12)), Fname (VARCHAR(12)), Age (INTEGER), Sex (VARCHAR(1)), Major (INTEGER), Advisor (INTEGER), city_code (VARCHAR(3)) Dorm: dormid (INTEGER), dorm_name (VARCHAR(20)), student_capacity (INTEGER), gender (VARCHAR(1)) Dorm_amenity: amenid (INTEGER), amenity_name (VARCHAR(25)) Has_amenity: dormid (INTEGER), amenid (INTEGER) Lives_in: stuid (INTEGER), dormid (INTEGER), room_number (INTEGER)
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
Find the name of amenities of the dorm where the student with last name Smith is living in.
Student: StuID (INTEGER), LName (VARCHAR(12)), Fname (VARCHAR(12)), Age (INTEGER), Sex (VARCHAR(1)), Major (INTEGER), Advisor (INTEGER), city_code (VARCHAR(3)) Dorm: dormid (INTEGER), dorm_name (VARCHAR(20)), student_capacity (INTEGER), gender (VARCHAR(1)) Dorm_amenity: amenid (INTEGER), amenity_name (VARCHAR(25)) Has_amenity: dormid (INTEGER), amenid (INTEGER) Lives_in: stuid (INTEGER), dormid (INTEGER), room_number (INTEGER)
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
What are the amenities in the dorm that a student who has the last name of Smith lives in?
Student: StuID (INTEGER), LName (VARCHAR(12)), Fname (VARCHAR(12)), Age (INTEGER), Sex (VARCHAR(1)), Major (INTEGER), Advisor (INTEGER), city_code (VARCHAR(3)) Dorm: dormid (INTEGER), dorm_name (VARCHAR(20)), student_capacity (INTEGER), gender (VARCHAR(1)) Dorm_amenity: amenid (INTEGER), amenity_name (VARCHAR(25)) Has_amenity: dormid (INTEGER), amenid (INTEGER) Lives_in: stuid (INTEGER), dormid (INTEGER), room_number (INTEGER)
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
How many customers are there?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(*) FROM customers
Count the number of customers.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(*) FROM customers
Find the emails and phone numbers of all the customers, ordered by email address and phone number.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
What are the emails and phone numbers of all customers, sorted by email address and phone number?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
Which city has the least number of customers whose type code is "Good Credit Rating"?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Return the city with the customer type code "Good Credit Rating" that had the fewest customers.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
List the name of all products along with the number of complaints that they have received.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
What are all the different product names, and how many complains has each received?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
Find the emails of customers who has filed a complaints of the product with the most complaints.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
Which products has been complained by the customer who has filed least amount of complaints?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
What is the phone number of the customer who has filed the most recent complaint?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Return the phone number of the customer who filed the complaint that was raised most recently.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Find the email and phone number of the customers who have never filed a complaint before.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
What are the emails and phone numbers of custoemrs who have never filed a complaint?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
Find the phone number of all the customers and staff.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What are the phone numbers of all customers and all staff members?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What is the description of the product named "Chocolate"?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_description FROM products WHERE product_name = "Chocolate"
Return the description of the product called "Chocolate".
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_description FROM products WHERE product_name = "Chocolate"
Find the name and category of the most expensive product.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
What is the name and category code of the product with the highest price?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
Find the prices of products which has never received a single complaint.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
What are the prices of products that have never gotten a complaint?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
What is the average price of the products for each category?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
Return the average price of products that have each category code.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
Find the last name of the staff member who processed the complaint of the cheapest product.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
What is the last name of the staff member in charge of the complaint on the product with the lowest price?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
Which complaint status has more than 3 records on file?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Return complaint status codes have more than 3 corresponding complaints?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Find the last name of the staff whose email address contains "wrau".
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
What are the last names of staff with email addressed containing the substring "wrau"?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
How many customers are there in the customer type with the most customers?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
Count the number of customers that have the customer type that is most common.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
What is the last name of the staff who has handled the first ever complaint?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
Return the last name of the staff member who handled the complaint with the earliest date raised.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
How many distinct complaint type codes are there in the database?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(DISTINCT complaint_type_code) FROM complaints
Count the number of different complaint type codes.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT count(DISTINCT complaint_type_code) FROM complaints
Find the address line 1 and 2 of the customer with email "vbogisich@example.org".
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
What are lines 1 and 2 of the addressed of the customer with the email "vbogisich@example.org"?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
Find the number of complaints with Product Failure type for each complaint status.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
Of complaints with the type code "Product Failure", how many had each different status code?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
What is first names of the top 5 staff who have handled the greatest number of complaints?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
Return the first names of the 5 staff members who have handled the most complaints.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
Which state has the most customers?
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
Give the state that has the most customers.
Staff: staff_id (INTEGER), gender (VARCHAR(1)), first_name (VARCHAR(80)), last_name (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Customers: customer_id (INTEGER), customer_type_code (VARCHAR(20)), address_line_1 (VARCHAR(80)), address_line_2 (VARCHAR(80)), town_city (VARCHAR(80)), state (VARCHAR(80)), email_address (VARCHAR(255)), phone_number (VARCHAR(80)) Products: product_id (INTEGER), parent_product_id (INTEGER), product_category_code (VARCHAR(20)), date_product_first_available (DATETIME), date_product_discontinued (DATETIME), product_name (VARCHAR(80)), product_description (VARCHAR(255)), product_price (DECIMAL(194)) Complaints: complaint_id (INTEGER), product_id (INTEGER), customer_id (INTEGER), complaint_outcome_code (VARCHAR(20)), complaint_status_code (VARCHAR(20)), complaint_type_code (VARCHAR(20)), date_complaint_raised (DATETIME), date_complaint_closed (DATETIME), staff_id (INTEGER)
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
How many submissions are there?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT count(*) FROM submission
Count the number of submissions.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT count(*) FROM submission
List the authors of submissions in ascending order of scores.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission ORDER BY Scores ASC
Find the author for each submission and list them in ascending order of submission score.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission ORDER BY Scores ASC
What are the authors of submissions and their colleges?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author , College FROM submission
For each submission, show the author and their affiliated college.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author , College FROM submission
Show the names of authors from college "Florida" or "Temple"
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
Which authors with submissions are from college "Florida" or "Temple"?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
What is the average score of submissions?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT avg(Scores) FROM submission
Compute the average score of submissions.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT avg(Scores) FROM submission
What is the author of the submission with the highest score?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
Find the author who achieved the highest score in a submission.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1
Show different colleges along with the number of authors of submission from each college.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College , COUNT(*) FROM submission GROUP BY College
For each college, return the college name and the count of authors with submissions from that college.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College , COUNT(*) FROM submission GROUP BY College
Show the most common college of authors of submissions.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
Which college has the most authors with submissions?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1
Show the colleges that have both authors with submission score larger than 90 and authors with submission score smaller than 80.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
Which colleges have both authors with submission score above 90 and authors with submission score below 80?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80
Show the authors of submissions and the acceptance results of their submissions.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
For each submission, find its author and acceptance result.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID
Show the result of the submission with the highest score.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
Which submission received the highest score in acceptance result. Show me the result.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID ORDER BY T2.Scores DESC LIMIT 1
Show each author and the number of workshops they submitted to.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
How many workshops did each author submit to? Return the author name and the number of workshops.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author , COUNT(DISTINCT T1.workshop_id) FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author
Show the authors who have submissions to more than one workshop.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
Which authors have submitted to more than one workshop?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT T2.Author FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID GROUP BY T2.Author HAVING COUNT(DISTINCT T1.workshop_id) > 1
Show the date and venue of each workshop in ascending alphabetical order of the venue.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Date , Venue FROM workshop ORDER BY Venue
Sort the each workshop in alphabetical order of the venue. Return the date and venue of each workshop.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Date , Venue FROM workshop ORDER BY Venue
List the authors who do not have submission to any workshop.
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
Which authors did not submit to any workshop?
workshop: Workshop_ID (INT), Date (TEXT), Venue (TEXT), Name (TEXT) submission: Submission_ID (INT), Scores (REAL), Author (TEXT), College (TEXT) Acceptance: Submission_ID (INT), Workshop_ID (INT), Result (TEXT)
SELECT Author FROM submission WHERE Submission_ID NOT IN (SELECT Submission_ID FROM acceptance)
Find the number of investors in total.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT count(*) FROM INVESTORS
Show all investor details.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT Investor_details FROM INVESTORS
Show all distinct lot details.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT DISTINCT lot_details FROM LOTS
Show the maximum amount of transaction.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT max(amount_of_transaction) FROM TRANSACTIONS
Show all date and share count of transactions.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT date_of_transaction , share_count FROM TRANSACTIONS
What is the total share of transactions?
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT sum(share_count) FROM TRANSACTIONS
Show all transaction ids with transaction code 'PUR'.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR'
Show all dates of transactions whose type code is "SALE".
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
Show the average amount of transactions with type code "SALE".
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT avg(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE"
Show the description of transaction type with code "PUR".
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR"
Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT min(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50
Show the maximum share count of transactions where the amount is smaller than 10000
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT max(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000
Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000
Show the transaction type descriptions and dates if the share count is smaller than 10.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT T1.transaction_type_description , T2.date_of_transaction FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10
Show details of all investors if they make any transaction with share count greater than 100.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100
How many distinct transaction types are used in the transactions?
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS
Return the lot details and investor ids.
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT lot_details , investor_id FROM LOTS
Return the lot details of lots that belong to investors with details "l"?
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l"
What are the purchase details of transactions with amount bigger than 10000?
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT T1.purchase_details FROM PURCHASES AS T1 JOIN TRANSACTIONS AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000
What are the sale details and dates of transactions with amount smaller than 3000?
Investors: investor_id (INTEGER), Investor_details (VARCHAR(255)) Lots: lot_id (INTEGER), investor_id (INTEGER), lot_details (VARCHAR(255)) Ref_Transaction_Types: transaction_type_code (VARCHAR(10)), transaction_type_description (VARCHAR(80)) Transactions: transaction_id (INTEGER), investor_id (INTEGER), transaction_type_code (VARCHAR(10)), date_of_transaction (DATETIME), amount_of_transaction (DECIMAL(194)), share_count (VARCHAR(40)), other_details (VARCHAR(255)) Sales: sales_transaction_id (INTEGER), sales_details (VARCHAR(255)) Purchases: purchase_transaction_id (INTEGER), purchase_details (VARCHAR(255)) Transactions_Lots: transaction_id (INTEGER), lot_id (INTEGER)
SELECT T1.sales_details , T2.date_of_transaction FROM SALES AS T1 JOIN TRANSACTIONS AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000