Question: Find the number of amenities for each of the dorms that can accommodate more than 100 students.

Context: CREATE TABLE dorm (dormid VARCHAR, student_capacity INTEGER); CREATE TABLE has_amenity (dormid VARCHAR)

Answer: [SQL] SELECT COUNT(*), T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid [/SQL]


Question: Find the number of students who is older than 20 in each dorm.

Context: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR, age INTEGER)

Answer: [SQL] SELECT COUNT(*), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name [/SQL]


Question: Find the first name of students who are living in the Smith Hall.

Context: CREATE TABLE student (fname VARCHAR, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)

Answer: [SQL] SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' [/SQL]


Question: Find the average age of students who are living in the dorm with the largest capacity.

Context: CREATE TABLE dorm (student_capacity INTEGER); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, student_capacity INTEGER)

Answer: [SQL] SELECT AVG(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT MAX(student_capacity) FROM dorm) [/SQL]


Question: Find the total number of students living in the male dorm (with gender M).

Context: CREATE TABLE dorm (dormid VARCHAR, gender VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M' [/SQL]


Question: Find the number of female students (with F sex) living in Smith Hall

Context: CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (stuid VARCHAR, sex VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F' [/SQL]


Question: Find the name of amenities Smith Hall dorm have.

Context: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dormid VARCHAR, dorm_name VARCHAR)

Answer: [SQL] 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 WHERE T1.dorm_name = 'Smith Hall' [/SQL]


Question: Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.

Answer: [SQL] 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 WHERE T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name [/SQL]


Question: Find the name of amenity that is most common in all dorms.

Context: CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR); CREATE TABLE has_amenity (amenid VARCHAR)

Answer: [SQL] SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the first name of students who are living in the dorm that has most number of amenities.

Context: CREATE TABLE dorm_amenity (amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABLE student (fname VARCHAR, stuid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR)

Answer: [SQL] SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: Find the name and capacity of the dorm with least number of amenities.

Context: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR); CREATE TABLE dorm (dorm_name VARCHAR, student_capacity VARCHAR, dormid VARCHAR)

Answer: [SQL] SELECT T1.dorm_name, T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: Find the name of dorms that do not have amenity TV Lounge.

Context: CREATE TABLE dorm (dorm_name VARCHAR, dormid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm (dorm_name VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR, amenity_name VARCHAR)

Answer: [SQL] SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_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 WHERE T3.amenity_name = 'TV Lounge' [/SQL]


Question: Find the first and last name of students who are living in the dorms that have amenity TV Lounge.

Context: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE student (fname VARCHAR, lname VARCHAR, stuid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR, amenity_name VARCHAR)

Answer: [SQL] SELECT T1.fname, T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid 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') [/SQL]


Question: Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.

Context: CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE student (fname VARCHAR, age VARCHAR, stuid VARCHAR); CREATE TABLE lives_in (stuid VARCHAR, dormid VARCHAR); CREATE TABLE dorm_amenity (amenid VARCHAR, amenity_name VARCHAR)

Answer: [SQL] SELECT T1.fname, T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE NOT T2.dormid 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') [/SQL]


Question: Find the name of amenities of the dorm where the student with last name Smith is living in.

Context: CREATE TABLE student (stuid VARCHAR, lname VARCHAR); CREATE TABLE dorm (dormid VARCHAR); CREATE TABLE lives_in (dormid VARCHAR, stuid VARCHAR); CREATE TABLE has_amenity (dormid VARCHAR, amenid VARCHAR); CREATE TABLE dorm_amenity (amenity_name VARCHAR, amenid VARCHAR)

Answer: [SQL] 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' [/SQL]


Question: Find the emails and phone numbers of all the customers, ordered by email address and phone number.

Context: CREATE TABLE customers (email_address VARCHAR, phone_number VARCHAR)

Answer: [SQL] SELECT email_address, phone_number FROM customers ORDER BY email_address, phone_number [/SQL]


Question: Which city has the least number of customers whose type code is "Good Credit Rating"?

Context: CREATE TABLE customers (town_city VARCHAR, customer_type_code VARCHAR)

Answer: [SQL] SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: List the name of all products along with the number of complaints that they have received.

Context: CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Find the emails of customers who has filed a complaints of the product with the most complaints.

Context: CREATE TABLE customers (email_address VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Which products has been complained by the customer who has filed least amount of complaints?

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: What is the phone number of the customer who has filed the most recent complaint?

Context: CREATE TABLE customers (phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE complaints (customer_id VARCHAR, date_complaint_raised VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Find the email and phone number of the customers who have never filed a complaint before.

Context: CREATE TABLE complaints (email_address VARCHAR, phone_number VARCHAR, customer_id VARCHAR); CREATE TABLE customers (email_address VARCHAR, phone_number VARCHAR, customer_id VARCHAR)

Answer: [SQL] SELECT email_address, phone_number FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM complaints) [/SQL]


Question: Find the phone number of all the customers and staff.

Context: CREATE TABLE staff (phone_number VARCHAR); CREATE TABLE customers (phone_number VARCHAR)

Answer: [SQL] SELECT phone_number FROM customers UNION SELECT phone_number FROM staff [/SQL]


Question: What is the description of the product named "Chocolate"?

Context: CREATE TABLE products (product_description VARCHAR, product_name VARCHAR)

Answer: [SQL] SELECT product_description FROM products WHERE product_name = "Chocolate" [/SQL]


Question: Find the name and category of the most expensive product.

Context: CREATE TABLE products (product_name VARCHAR, product_category_code VARCHAR, product_price VARCHAR)

Answer: [SQL] SELECT product_name, product_category_code FROM products ORDER BY product_price DESC LIMIT 1 [/SQL]


Question: Find the prices of products which has never received a single complaint.

Context: CREATE TABLE products (product_price VARCHAR, product_id VARCHAR); CREATE TABLE complaints (product_price VARCHAR, product_id VARCHAR)

Answer: [SQL] SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints) [/SQL]


Question: What is the average price of the products for each category?

Context: CREATE TABLE products (product_category_code VARCHAR, product_price INTEGER)

Answer: [SQL] SELECT AVG(product_price), product_category_code FROM products GROUP BY product_category_code [/SQL]


Question: Find the last name of the staff member who processed the complaint of the cheapest product.

Context: CREATE TABLE products (product_id VARCHAR, product_price VARCHAR); CREATE TABLE complaints (staff_id VARCHAR, product_id VARCHAR); CREATE TABLE staff (last_name VARCHAR, staff_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Which complaint status has more than 3 records on file?

Context: CREATE TABLE complaints (complaint_status_code VARCHAR)

Answer: [SQL] SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING COUNT(*) > 3 [/SQL]


Question: Find the last name of the staff whose email address contains "wrau".

Context: CREATE TABLE staff (last_name VARCHAR, email_address VARCHAR)

Answer: [SQL] SELECT last_name FROM staff WHERE email_address LIKE "%wrau%" [/SQL]


Question: How many customers are there in the customer type with the most customers?

Context: CREATE TABLE customers (customer_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers GROUP BY customer_type_code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the last name of the staff who has handled the first ever complaint?

Context: CREATE TABLE staff (last_name VARCHAR, staff_id VARCHAR); CREATE TABLE complaints (staff_id VARCHAR, date_complaint_raised VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: How many distinct complaint type codes are there in the database?

Context: CREATE TABLE complaints (complaint_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT complaint_type_code) FROM complaints [/SQL]


Question: Find the address line 1 and 2 of the customer with email "vbogisich@example.org".

Context: CREATE TABLE customers (address_line_1 VARCHAR, address_line_2 VARCHAR, email_address VARCHAR)

Answer: [SQL] SELECT address_line_1, address_line_2 FROM customers WHERE email_address = "vbogisich@example.org" [/SQL]


Question: Find the number of complaints with Product Failure type for each complaint status.

Context: CREATE TABLE complaints (complaint_status_code VARCHAR, complaint_type_code VARCHAR)

Answer: [SQL] SELECT complaint_status_code, COUNT(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code [/SQL]


Question: What is first names of the top 5 staff who have handled the greatest number of complaints?

Context: CREATE TABLE complaints (staff_id VARCHAR); CREATE TABLE staff (first_name VARCHAR, staff_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Which state has the most customers?

Context: CREATE TABLE customers (state VARCHAR)

Answer: [SQL] SELECT state FROM customers GROUP BY state ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: How many submissions are there?

Context: CREATE TABLE submission (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM submission [/SQL]


Question: List the authors of submissions in ascending order of scores.

Context: CREATE TABLE submission (Author VARCHAR, Scores VARCHAR)

Answer: [SQL] SELECT Author FROM submission ORDER BY Scores [/SQL]


Question: What are the authors of submissions and their colleges?

Context: CREATE TABLE submission (Author VARCHAR, College VARCHAR)

Answer: [SQL] SELECT Author, College FROM submission [/SQL]


Question: Show the names of authors from college "Florida" or "Temple"

Answer: [SQL] SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple" [/SQL]


Question: What is the average score of submissions?

Context: CREATE TABLE submission (Scores INTEGER)

Answer: [SQL] SELECT AVG(Scores) FROM submission [/SQL]


Question: What is the author of the submission with the highest score?

Answer: [SQL] SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1 [/SQL]


Question: Show different colleges along with the number of authors of submission from each college.

Context: CREATE TABLE submission (College VARCHAR)

Answer: [SQL] SELECT College, COUNT(*) FROM submission GROUP BY College [/SQL]


Question: Show the most common college of authors of submissions.

Answer: [SQL] SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the colleges that have both authors with submission score larger than 90 and authors with submission score smaller than 80.

Context: CREATE TABLE submission (College VARCHAR, Scores INTEGER)

Answer: [SQL] SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80 [/SQL]


Question: Show the authors of submissions and the acceptance results of their submissions.

Context: CREATE TABLE acceptance (Result VARCHAR, Submission_ID VARCHAR); CREATE TABLE submission (Author VARCHAR, Submission_ID VARCHAR)

Answer: [SQL] SELECT T2.Author, T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID [/SQL]


Question: Show the result of the submission with the highest score.

Context: CREATE TABLE acceptance (Result VARCHAR, Submission_ID VARCHAR); CREATE TABLE submission (Submission_ID VARCHAR, Scores VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show each author and the number of workshops they submitted to.

Context: CREATE TABLE submission (Author VARCHAR, Submission_ID VARCHAR); CREATE TABLE acceptance (workshop_id VARCHAR, Submission_ID VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the authors who have submissions to more than one workshop.

Context: CREATE TABLE submission (Author VARCHAR, Submission_ID VARCHAR); CREATE TABLE acceptance (Submission_ID VARCHAR, workshop_id VARCHAR)

Answer: [SQL] 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 [/SQL]


Question: Show the date and venue of each workshop in ascending alphabetical order of the venue.

Context: CREATE TABLE workshop (Date VARCHAR, Venue VARCHAR)

Answer: [SQL] SELECT Date, Venue FROM workshop ORDER BY Venue [/SQL]


Question: List the authors who do not have submission to any workshop.

Context: CREATE TABLE acceptance (Author VARCHAR, Submission_ID VARCHAR); CREATE TABLE submission (Author VARCHAR, Submission_ID VARCHAR)

Answer: [SQL] SELECT Author FROM submission WHERE NOT Submission_ID IN (SELECT Submission_ID FROM acceptance) [/SQL]


Question: Find the number of investors in total.

Context: CREATE TABLE INVESTORS (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM INVESTORS [/SQL]


Question: Show all investor details.

Context: CREATE TABLE INVESTORS (Investor_details VARCHAR)

Answer: [SQL] SELECT Investor_details FROM INVESTORS [/SQL]


Question: Show all distinct lot details.

Context: CREATE TABLE LOTS (lot_details VARCHAR)

Answer: [SQL] SELECT DISTINCT lot_details FROM LOTS [/SQL]


Question: Show the maximum amount of transaction.

Context: CREATE TABLE TRANSACTIONS (amount_of_transaction INTEGER)

Answer: [SQL] SELECT MAX(amount_of_transaction) FROM TRANSACTIONS [/SQL]


Question: Show all date and share count of transactions.

Context: CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, share_count VARCHAR)

Answer: [SQL] SELECT date_of_transaction, share_count FROM TRANSACTIONS [/SQL]


Question: What is the total share of transactions?

Context: CREATE TABLE TRANSACTIONS (share_count INTEGER)

Answer: [SQL] SELECT SUM(share_count) FROM TRANSACTIONS [/SQL]


Question: Show all transaction ids with transaction code 'PUR'.

Context: CREATE TABLE TRANSACTIONS (transaction_id VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR' [/SQL]


Question: Show all dates of transactions whose type code is "SALE".

Context: CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE" [/SQL]


Question: Show the average amount of transactions with type code "SALE".

Context: CREATE TABLE TRANSACTIONS (amount_of_transaction INTEGER, transaction_type_code VARCHAR)

Answer: [SQL] SELECT AVG(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" [/SQL]


Question: Show the description of transaction type with code "PUR".

Context: CREATE TABLE Ref_Transaction_Types (transaction_type_description VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR" [/SQL]


Question: Show the minimum amount of transactions whose type code is "PUR" and whose share count is bigger than 50.

Context: CREATE TABLE TRANSACTIONS (amount_of_transaction INTEGER, transaction_type_code VARCHAR, share_count VARCHAR)

Answer: [SQL] SELECT MIN(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50 [/SQL]


Question: Show the maximum share count of transactions where the amount is smaller than 10000

Context: CREATE TABLE TRANSACTIONS (share_count INTEGER, amount_of_transaction INTEGER)

Answer: [SQL] SELECT MAX(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000 [/SQL]


Question: Show the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000.

Context: CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, share_count VARCHAR, amount_of_transaction VARCHAR)

Answer: [SQL] SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000 [/SQL]


Question: Show the transaction type descriptions and dates if the share count is smaller than 10.

Context: CREATE TABLE Ref_Transaction_Types (transaction_type_description VARCHAR, transaction_type_code VARCHAR); CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, transaction_type_code VARCHAR, share_count INTEGER)

Answer: [SQL] 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 [/SQL]


Question: Show details of all investors if they make any transaction with share count greater than 100.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR, share_count INTEGER); CREATE TABLE INVESTORS (Investor_details VARCHAR, investor_id VARCHAR)

Answer: [SQL] SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100 [/SQL]


Question: How many distinct transaction types are used in the transactions?

Context: CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS [/SQL]


Question: Return the lot details and investor ids.

Context: CREATE TABLE LOTS (lot_details VARCHAR, investor_id VARCHAR)

Answer: [SQL] SELECT lot_details, investor_id FROM LOTS [/SQL]


Question: Return the lot details of lots that belong to investors with details "l"?

Context: CREATE TABLE LOTS (lot_details VARCHAR, investor_id VARCHAR); CREATE TABLE INVESTORS (investor_id VARCHAR, Investor_details VARCHAR)

Answer: [SQL] SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l" [/SQL]


Question: What are the purchase details of transactions with amount bigger than 10000?

Context: CREATE TABLE PURCHASES (purchase_details VARCHAR, purchase_transaction_id VARCHAR); CREATE TABLE TRANSACTIONS (transaction_id VARCHAR, amount_of_transaction INTEGER)

Answer: [SQL] 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 [/SQL]


Question: What are the sale details and dates of transactions with amount smaller than 3000?

Context: CREATE TABLE SALES (sales_details VARCHAR, sales_transaction_id VARCHAR); CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, transaction_id VARCHAR, amount_of_transaction INTEGER)

Answer: [SQL] 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 [/SQL]


Question: What are the lot details of lots associated with transactions with share count smaller than 50?

Context: CREATE TABLE LOTS (lot_details VARCHAR, lot_id VARCHAR); CREATE TABLE TRANSACTIONS_LOTS (transaction_id VARCHAR); CREATE TABLE TRANSACTIONS (transaction_id VARCHAR, share_count INTEGER)

Answer: [SQL] SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count < 50 [/SQL]


Question: What are the lot details of lots associated with transactions whose share count is bigger than 100 and whose type code is "PUR"?

Context: CREATE TABLE LOTS (lot_details VARCHAR, lot_id VARCHAR); CREATE TABLE TRANSACTIONS_LOTS (transaction_id VARCHAR); CREATE TABLE TRANSACTIONS (transaction_id VARCHAR, share_count VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT T1.lot_details FROM LOTS AS T1 JOIN TRANSACTIONS_LOTS AS T2 ON T1.lot_id = T2.transaction_id JOIN TRANSACTIONS AS T3 ON T2.transaction_id = T3.transaction_id WHERE T3.share_count > 100 AND T3.transaction_type_code = "PUR" [/SQL]


Question: Show the average transaction amount for different transaction types.

Context: CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR, amount_of_transaction INTEGER)

Answer: [SQL] SELECT transaction_type_code, AVG(amount_of_transaction) FROM TRANSACTIONS GROUP BY transaction_type_code [/SQL]


Question: Show the maximum and minimum share count of different transaction types.

Context: CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR, share_count INTEGER)

Answer: [SQL] SELECT transaction_type_code, MAX(share_count), MIN(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code [/SQL]


Question: Show the average share count of transactions for different investors.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR, share_count INTEGER)

Answer: [SQL] SELECT investor_id, AVG(share_count) FROM TRANSACTIONS GROUP BY investor_id [/SQL]


Question: Show the average share count of transactions each each investor, ordered by average share count.

Answer: [SQL] SELECT investor_id, AVG(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY AVG(share_count) [/SQL]


Question: Show the average amount of transactions for different investors.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR, amount_of_transaction INTEGER)

Answer: [SQL] SELECT investor_id, AVG(amount_of_transaction) FROM TRANSACTIONS GROUP BY investor_id [/SQL]


Question: Show the average amount of transactions for different lots.

Context: CREATE TABLE TRANSACTIONS (transaction_id VARCHAR); CREATE TABLE Transactions_Lots (lot_id VARCHAR, transaction_id VARCHAR)

Answer: [SQL] SELECT T2.lot_id, AVG(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id [/SQL]


Question: Show the average amount of transactions for different lots, ordered by average amount of transactions.

Answer: [SQL] SELECT T2.lot_id, AVG(amount_of_transaction) FROM TRANSACTIONS AS T1 JOIN Transactions_Lots AS T2 ON T1.transaction_id = T2.transaction_id GROUP BY T2.lot_id ORDER BY AVG(amount_of_transaction) [/SQL]


Question: Show the number of transactions with transaction type code "SALE" for different investors if it is larger than 0.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT investor_id, COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id [/SQL]


Question: Show the number of transactions for different investors.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR)

Answer: [SQL] SELECT investor_id, COUNT(*) FROM TRANSACTIONS GROUP BY investor_id [/SQL]


Question: Show the transaction type code that occurs the fewest times.

Answer: [SQL] SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: Show the transaction type code that occurs the most frequently.

Answer: [SQL] SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the description of the transaction type that occurs most frequently.

Context: CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR); CREATE TABLE Ref_Transaction_Types (transaction_type_description VARCHAR, transaction_type_code VARCHAR)

Answer: [SQL] SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the id and details of the investor that has the largest number of transactions.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR); CREATE TABLE INVESTORS (Investor_details VARCHAR, investor_id VARCHAR)

Answer: [SQL] SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the id and details for the investors who have the top 3 number of transactions.

Answer: [SQL] SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id ORDER BY COUNT(*) DESC LIMIT 3 [/SQL]


Question: Show the ids of the investors who have at least two transactions.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR); CREATE TABLE INVESTORS (investor_id VARCHAR)

Answer: [SQL] SELECT T2.investor_id FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id GROUP BY T2.investor_id HAVING COUNT(*) >= 2 [/SQL]


Question: Show the ids and details of the investors who have at least two transactions with type code "SALE".

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR, transaction_type_code VARCHAR); CREATE TABLE INVESTORS (Investor_details VARCHAR, investor_id VARCHAR)

Answer: [SQL] SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2 [/SQL]


Question: What are the dates of transactions with at least 100 share count or amount bigger than 100?

Context: CREATE TABLE TRANSACTIONS (date_of_transaction VARCHAR, share_count VARCHAR, amount_of_transaction VARCHAR)

Answer: [SQL] SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100 [/SQL]


Question: What are the details of all sales and purchases?

Context: CREATE TABLE purchases (sales_details VARCHAR, purchase_details VARCHAR); CREATE TABLE sales (sales_details VARCHAR, purchase_details VARCHAR)

Answer: [SQL] SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases [/SQL]


Question: What are the details of the lots which are not used in any transactions?

Context: CREATE TABLE Lots (lot_details VARCHAR, lot_id VARCHAR); CREATE TABLE Lots (lot_details VARCHAR); CREATE TABLE transactions_lots (lot_id VARCHAR)

Answer: [SQL] SELECT lot_details FROM Lots EXCEPT SELECT T1.lot_details FROM Lots AS T1 JOIN transactions_lots AS T2 ON T1.lot_id = T2.lot_id [/SQL]


Question: How many available hotels are there in total?

Context: CREATE TABLE HOTELS (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM HOTELS [/SQL]


Question: What are the price ranges of hotels?

Context: CREATE TABLE HOTELS (price_range VARCHAR)

Answer: [SQL] SELECT price_range FROM HOTELS [/SQL]


Question: Show all distinct location names.

Context: CREATE TABLE LOCATIONS (Location_Name VARCHAR)

Answer: [SQL] SELECT DISTINCT Location_Name FROM LOCATIONS [/SQL]


Question: Show the names and details of all the staff members.

Context: CREATE TABLE Staff (Name VARCHAR, Other_Details VARCHAR)

Answer: [SQL] SELECT Name, Other_Details FROM Staff [/SQL]


Question: Show details of all visitors.

Context: CREATE TABLE VISITORS (Tourist_Details VARCHAR)

Answer: [SQL] SELECT Tourist_Details FROM VISITORS [/SQL]


Question: Show the price ranges of hotels with 5 star ratings.

Context: CREATE TABLE HOTELS (price_range VARCHAR, star_rating_code VARCHAR)

Answer: [SQL] SELECT price_range FROM HOTELS WHERE star_rating_code = "5" [/SQL]


Question: Show the average price range of hotels that have 5 star ratings and allow pets.

Context: CREATE TABLE HOTELS (price_range INTEGER, star_rating_code VARCHAR, pets_allowed_yn VARCHAR)

Answer: [SQL] SELECT AVG(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1 [/SQL]


Question: What is the address of the location "UK Gallery"?

Context: CREATE TABLE LOCATIONS (Address VARCHAR, Location_Name VARCHAR)

Answer: [SQL] SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery" [/SQL]


Question: What is the detail of the location UK Gallery?

Context: CREATE TABLE LOCATIONS (Other_Details VARCHAR, Location_Name VARCHAR)

Answer: [SQL] SELECT Other_Details FROM LOCATIONS WHERE Location_Name = "UK Gallery" [/SQL]


Question: Which location names contain the word "film"?

Answer: [SQL] SELECT Location_Name FROM LOCATIONS WHERE Location_Name LIKE "%film%" [/SQL]


Question: How many distinct names are associated with all the photos?

Context: CREATE TABLE PHOTOS (Name VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Name) FROM PHOTOS [/SQL]


Question: What are the distinct visit dates?

Context: CREATE TABLE VISITS (Visit_Date VARCHAR)

Answer: [SQL] SELECT DISTINCT Visit_Date FROM VISITS [/SQL]


Question: What are the names of the tourist attractions that can be accessed by bus?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Name VARCHAR, How_to_Get_There VARCHAR)

Answer: [SQL] SELECT Name FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" [/SQL]


Question: What are the names and opening hours of the tourist attractions that can be accessed by bus or walk?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Name VARCHAR, Opening_Hours VARCHAR, How_to_Get_There VARCHAR)

Answer: [SQL] SELECT Name, Opening_Hours FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" OR How_to_Get_There = "walk" [/SQL]


Question: What are the star rating descriptions of the hotels with price above 10000?

Context: CREATE TABLE HOTELS (star_rating_code VARCHAR, price_range INTEGER); CREATE TABLE Ref_Hotel_Star_Ratings (star_rating_description VARCHAR, star_rating_code VARCHAR)

Answer: [SQL] SELECT T2.star_rating_description FROM HOTELS AS T1 JOIN Ref_Hotel_Star_Ratings AS T2 ON T1.star_rating_code = T2.star_rating_code WHERE T1.price_range > 10000 [/SQL]


Question: What are the details and opening hours of the museums?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Opening_Hours VARCHAR, Tourist_Attraction_ID VARCHAR); CREATE TABLE MUSEUMS (Museum_Details VARCHAR, Museum_ID VARCHAR)

Answer: [SQL] SELECT T1.Museum_Details, T2.Opening_Hours FROM MUSEUMS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Museum_ID = T2.Tourist_Attraction_ID [/SQL]


Question: What is the name of the tourist attraction that is associated with the photo "game1"?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Name VARCHAR, Tourist_Attraction_ID VARCHAR); CREATE TABLE PHOTOS (Tourist_Attraction_ID VARCHAR, Name VARCHAR)

Answer: [SQL] SELECT T2.Name FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T1.Name = "game1" [/SQL]


Question: What are the names and descriptions of the photos taken at the tourist attraction "film festival"?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Tourist_Attraction_ID VARCHAR, Name VARCHAR); CREATE TABLE PHOTOS (Name VARCHAR, Description VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T1.Description FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = "film festival" [/SQL]


Question: What are the details and ways to get to tourist attractions related to royal family?

Context: CREATE TABLE TOURIST_ATTRACTIONS (How_to_Get_There VARCHAR, Tourist_Attraction_ID VARCHAR); CREATE TABLE ROYAL_FAMILY (Royal_Family_Details VARCHAR, Royal_Family_ID VARCHAR)

Answer: [SQL] SELECT T1.Royal_Family_Details, T2.How_to_Get_There FROM ROYAL_FAMILY AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Royal_Family_ID = T2.Tourist_Attraction_ID [/SQL]


Question: What are the details of the shops that can be accessed by walk?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Tourist_Attraction_ID VARCHAR, How_to_Get_There VARCHAR); CREATE TABLE SHOPS (Shop_Details VARCHAR, Shop_ID VARCHAR)

Answer: [SQL] SELECT T1.Shop_Details FROM SHOPS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Shop_ID = T2.Tourist_Attraction_ID WHERE T2.How_to_Get_There = "walk" [/SQL]


Question: What is the name of the staff that is in charge of the attraction named "US museum"?

Context: CREATE TABLE TOURIST_ATTRACTIONS (Tourist_Attraction_ID VARCHAR, Name VARCHAR); CREATE TABLE STAFF (Name VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM STAFF AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = "US museum" [/SQL]


Question: What are the details of the markets that can be accessed by walk or bus?

Context: CREATE TABLE Street_Markets (Market_Details VARCHAR, Market_ID VARCHAR); CREATE TABLE TOURIST_ATTRACTIONS (Tourist_Attraction_ID VARCHAR, How_to_Get_There VARCHAR)

Answer: [SQL] SELECT T1.Market_Details FROM Street_Markets AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Market_ID = T2.Tourist_Attraction_ID WHERE T2.How_to_Get_There = "walk" OR T2.How_to_Get_There = "bus" [/SQL]


Question: What are the visit date and details of the visitor whose detail is 'Vincent'?

Context: CREATE TABLE VISITORS (Tourist_ID VARCHAR, Tourist_Details VARCHAR); CREATE TABLE VISITS (Visit_Date VARCHAR, Visit_Details VARCHAR, Tourist_ID VARCHAR)

Answer: [SQL] SELECT T2.Visit_Date, T2.Visit_Details FROM VISITORS AS T1 JOIN VISITS AS T2 ON T1.Tourist_ID = T2.Tourist_ID WHERE T1.Tourist_Details = "Vincent" [/SQL]


Question: Which tourist attractions does the visitor with detail 'Vincent' visit?

Context: CREATE TABLE VISITS (Tourist_Attraction_ID VARCHAR, Tourist_ID VARCHAR); CREATE TABLE VISITORS (Tourist_ID VARCHAR, Tourist_Details VARCHAR); CREATE TABLE Tourist_Attractions (Name VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID JOIN VISITORS AS T3 ON T2.Tourist_ID = T3.Tourist_ID WHERE T3.Tourist_Details = "Vincent" [/SQL]


Question: What are the names of the tourist attractions and the dates when the tourists named Vincent or Vivian visited there?

Context: CREATE TABLE VISITORS (Tourist_ID VARCHAR, Tourist_Details VARCHAR); CREATE TABLE VISITS (Visit_Date VARCHAR, Tourist_Attraction_ID VARCHAR, Tourist_ID VARCHAR); CREATE TABLE Tourist_Attractions (Name VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T3.Visit_Date FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Vincent" OR T2.Tourist_Details = "Vivian" [/SQL]


Question: Show the average price of hotels for each star rating code.

Context: CREATE TABLE HOTELS (star_rating_code VARCHAR, price_range INTEGER)

Answer: [SQL] SELECT star_rating_code, AVG(price_range) FROM HOTELS GROUP BY star_rating_code [/SQL]


Question: Show the average price of hotels for different pet policy.

Context: CREATE TABLE HOTELS (pets_allowed_yn VARCHAR, price_range INTEGER)

Answer: [SQL] SELECT pets_allowed_yn, AVG(price_range) FROM HOTELS GROUP BY pets_allowed_yn [/SQL]


Question: Show the id and star rating of each hotel, ordered by its price from low to high.

Context: CREATE TABLE HOTELS (hotel_id VARCHAR, star_rating_code VARCHAR, price_range VARCHAR)

Answer: [SQL] SELECT hotel_id, star_rating_code FROM HOTELS ORDER BY price_range [/SQL]


Question: Show the details of the top 3 most expensive hotels.

Context: CREATE TABLE HOTELS (other_hotel_details VARCHAR, price_range VARCHAR)

Answer: [SQL] SELECT other_hotel_details FROM HOTELS ORDER BY price_range DESC LIMIT 3 [/SQL]


Question: Show the details and star ratings of the 3 least expensive hotels.

Context: CREATE TABLE HOTELS (other_hotel_details VARCHAR, star_rating_code VARCHAR, price_range VARCHAR)

Answer: [SQL] SELECT other_hotel_details, star_rating_code FROM HOTELS ORDER BY price_range LIMIT 3 [/SQL]


Question: Show the transportation method most people choose to get to tourist attractions.

Context: CREATE TABLE Tourist_Attractions (How_to_Get_There VARCHAR)

Answer: [SQL] SELECT How_to_Get_There FROM Tourist_Attractions GROUP BY How_to_Get_There ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show the description and code of the attraction type most tourist attractions belong to.

Context: CREATE TABLE Ref_Attraction_Types (Attraction_Type_Description VARCHAR, Attraction_Type_Code VARCHAR); CREATE TABLE Tourist_Attractions (Attraction_Type_Code VARCHAR)

Answer: [SQL] SELECT T1.Attraction_Type_Description, T2.Attraction_Type_Code FROM Ref_Attraction_Types AS T1 JOIN Tourist_Attractions AS T2 ON T1.Attraction_Type_Code = T2.Attraction_Type_Code GROUP BY T2.Attraction_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show different ways to get to attractions and the number of attractions that can be accessed in the corresponding way.

Answer: [SQL] SELECT How_to_Get_There, COUNT(*) FROM Tourist_Attractions GROUP BY How_to_Get_There [/SQL]


Question: Show different tourist attractions' names, ids, and the corresponding number of visits.

Context: CREATE TABLE VISITS (Tourist_Attraction_ID VARCHAR); CREATE TABLE Tourist_Attractions (Name VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T2.Tourist_Attraction_ID, COUNT(*) FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID [/SQL]


Question: Show the names and ids of tourist attractions that are visited at least two times.

Answer: [SQL] SELECT T1.Name, T2.Tourist_Attraction_ID FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID HAVING COUNT(*) >= 2 [/SQL]


Question: Show the names and ids of tourist attractions that are visited at most once.

Answer: [SQL] SELECT T1.Name, T1.Tourist_Attraction_ID FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID HAVING COUNT(*) <= 1 [/SQL]


Question: What are the names of tourist attractions that can be reached by walk or is at address 660 Shea Crescent?

Context: CREATE TABLE Tourist_Attractions (Name VARCHAR, Location_ID VARCHAR, How_to_Get_There VARCHAR); CREATE TABLE Locations (Location_ID VARCHAR, Address VARCHAR)

Answer: [SQL] SELECT T2.Name FROM Locations AS T1 JOIN Tourist_Attractions AS T2 ON T1.Location_ID = T2.Location_ID WHERE T1.Address = "660 Shea Crescent" OR T2.How_to_Get_There = "walk" [/SQL]


Question: What are the names of the tourist attractions that have parking or shopping as their feature details?

Context: CREATE TABLE Tourist_Attraction_Features (tourist_attraction_id VARCHAR, Feature_ID VARCHAR); CREATE TABLE Features (Feature_ID VARCHAR, feature_Details VARCHAR); CREATE TABLE Tourist_Attractions (Name VARCHAR, tourist_attraction_id VARCHAR)

Answer: [SQL] SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN Tourist_Attraction_Features AS T2 ON T1.tourist_attraction_id = T2.tourist_attraction_id JOIN Features AS T3 ON T2.Feature_ID = T3.Feature_ID WHERE T3.feature_Details = 'park' UNION SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN Tourist_Attraction_Features AS T2 ON T1.tourist_attraction_id = T2.tourist_attraction_id JOIN Features AS T3 ON T2.Feature_ID = T3.Feature_ID WHERE T3.feature_Details = 'shopping' [/SQL]


Question: What are the names of tourist attractions that can be reached by bus or is at address 254 Ottilie Junction?

Answer: [SQL] SELECT T2.Name FROM Locations AS T1 JOIN Tourist_Attractions AS T2 ON T1.Location_ID = T2.Location_ID WHERE T1.Address = "254 Ottilie Junction" OR T2.How_to_Get_There = "bus" [/SQL]


Question: What are the names of the tourist attractions Vincent and Marcelle visit?

Context: CREATE TABLE VISITS (Tourist_Attraction_ID VARCHAR, Tourist_ID VARCHAR); CREATE TABLE VISITORS (Tourist_Details VARCHAR, Tourist_ID VARCHAR); CREATE TABLE Tourist_Attractions (Name VARCHAR, Tourist_Attraction_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Vincent" INTERSECT SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Marcelle" [/SQL]


Question: What are the names of tourist attraction that Alison visited but Rosalind did not visit?

Answer: [SQL] SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Alison" EXCEPT SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITORS AS T2 JOIN VISITS AS T3 ON T1.Tourist_Attraction_ID = T3.Tourist_Attraction_ID AND T2.Tourist_ID = T3.Tourist_ID WHERE T2.Tourist_Details = "Rosalind" [/SQL]


Question: How many tourists did not make any visit?

Context: CREATE TABLE Visitors (Tourist_ID VARCHAR); CREATE TABLE Visits (Tourist_ID VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Visitors WHERE NOT Tourist_ID IN (SELECT Tourist_ID FROM Visits) [/SQL]


Question: How many video games exist?

Context: CREATE TABLE Video_games (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM Video_games [/SQL]


Question: How many video game types exist?

Context: CREATE TABLE Video_games (gtype VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT gtype) FROM Video_games [/SQL]


Question: Show all video game types.

Answer: [SQL] SELECT DISTINCT gtype FROM Video_games [/SQL]


Question: Show all video games and their types in the order of their names.

Context: CREATE TABLE Video_games (gname VARCHAR, gtype VARCHAR)

Answer: [SQL] SELECT gname, gtype FROM Video_games ORDER BY gname [/SQL]


Question: Show all video games with type Collectible card game.

Answer: [SQL] SELECT gname FROM Video_games WHERE gtype = "Collectible card game" [/SQL]


Question: What is the type of video game Call of Destiny.

Context: CREATE TABLE Video_games (gtype VARCHAR, gname VARCHAR)

Answer: [SQL] SELECT gtype FROM Video_games WHERE gname = "Call of Destiny" [/SQL]


Question: How many video games have type Massively multiplayer online game?

Answer: [SQL] SELECT COUNT(*) FROM Video_games WHERE gtype = "Massively multiplayer online game" [/SQL]


Question: Show all video game types and the number of video games in each type.

Answer: [SQL] SELECT gtype, COUNT(*) FROM Video_games GROUP BY gtype [/SQL]


Question: Which game type has most number of games?

Answer: [SQL] SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which game type has least number of games?

Answer: [SQL] SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) LIMIT 1 [/SQL]


Question: Show ids for all students who live in CHI.

Context: CREATE TABLE Student (StuID VARCHAR, city_code VARCHAR)

Answer: [SQL] SELECT StuID FROM Student WHERE city_code = "CHI" [/SQL]


Question: Show ids for all students who have advisor 1121.

Context: CREATE TABLE Student (StuID VARCHAR, Advisor VARCHAR)

Answer: [SQL] SELECT StuID FROM Student WHERE Advisor = 1121 [/SQL]


Question: Show first name for all students with major 600.

Context: CREATE TABLE Student (Fname VARCHAR, Major VARCHAR)

Answer: [SQL] SELECT Fname FROM Student WHERE Major = 600 [/SQL]


Question: Show the average, minimum, and maximum age for different majors.

Context: CREATE TABLE Student (major VARCHAR, age INTEGER)

Answer: [SQL] SELECT major, AVG(age), MIN(age), MAX(age) FROM Student GROUP BY major [/SQL]


Question: Show all advisors who have at least two students.

Context: CREATE TABLE Student (advisor VARCHAR)

Answer: [SQL] SELECT advisor FROM Student GROUP BY advisor HAVING COUNT(*) >= 2 [/SQL]


Question: How many sports do we have?

Context: CREATE TABLE Sportsinfo (sportname VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT sportname) FROM Sportsinfo [/SQL]


Question: How many students play sports?

Context: CREATE TABLE Sportsinfo (StuID VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT StuID) FROM Sportsinfo [/SQL]


Question: List ids for all student who are on scholarship.

Context: CREATE TABLE Sportsinfo (StuID VARCHAR, onscholarship VARCHAR)

Answer: [SQL] SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y' [/SQL]


Question: Show last names for all student who are on scholarship.

Context: CREATE TABLE Student (Lname VARCHAR, StuID VARCHAR); CREATE TABLE Sportsinfo (StuID VARCHAR, onscholarship VARCHAR)

Answer: [SQL] SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y' [/SQL]


Question: How many games are played for all students?

Context: CREATE TABLE Sportsinfo (gamesplayed INTEGER)

Answer: [SQL] SELECT SUM(gamesplayed) FROM Sportsinfo [/SQL]


Question: How many games are played for all football games by students on scholarship?

Context: CREATE TABLE Sportsinfo (gamesplayed INTEGER, sportname VARCHAR, onscholarship VARCHAR)

Answer: [SQL] SELECT SUM(gamesplayed) FROM Sportsinfo WHERE sportname = "Football" AND onscholarship = 'Y' [/SQL]


Question: Show all sport name and the number of students.

Answer: [SQL] SELECT sportname, COUNT(*) FROM Sportsinfo GROUP BY sportname [/SQL]


Question: Show all student IDs with the number of sports and total number of games played

Context: CREATE TABLE Sportsinfo (StuID VARCHAR, gamesplayed INTEGER)

Answer: [SQL] SELECT StuID, COUNT(*), SUM(gamesplayed) FROM Sportsinfo GROUP BY StuID [/SQL]


Question: Show all student IDs with more than total 10 hours per week on all sports played.

Context: CREATE TABLE Sportsinfo (StuID VARCHAR, hoursperweek INTEGER)

Answer: [SQL] SELECT StuID FROM Sportsinfo GROUP BY StuID HAVING SUM(hoursperweek) > 10 [/SQL]


Question: What is the first name and last name of the student who have most number of sports?

Context: CREATE TABLE Student (Fname VARCHAR, Lname VARCHAR, StuID VARCHAR); CREATE TABLE Sportsinfo (StuID VARCHAR)

Answer: [SQL] SELECT T2.Fname, T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID GROUP BY T1.StuID ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which sport has most number of students on scholarship?

Context: CREATE TABLE Sportsinfo (sportname VARCHAR, onscholarship VARCHAR)

Answer: [SQL] SELECT sportname FROM Sportsinfo WHERE onscholarship = 'Y' GROUP BY sportname ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Show student ids who don't have any sports.

Context: CREATE TABLE Sportsinfo (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR)

Answer: [SQL] SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo [/SQL]


Question: Show student ids who are on scholarship and have major 600.

Context: CREATE TABLE Sportsinfo (StuID VARCHAR, major VARCHAR, onscholarship VARCHAR); CREATE TABLE Student (StuID VARCHAR, major VARCHAR, onscholarship VARCHAR)

Answer: [SQL] SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y' [/SQL]


Question: Show student ids who are female and play football.

Context: CREATE TABLE Sportsinfo (StuID VARCHAR, sex VARCHAR, sportname VARCHAR); CREATE TABLE Student (StuID VARCHAR, sex VARCHAR, sportname VARCHAR)

Answer: [SQL] SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football" [/SQL]


Question: Show all male student ids who don't play football.

Answer: [SQL] SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football" [/SQL]


Question: Show total hours per week and number of games played for student David Shieber.

Context: CREATE TABLE Student (StuID VARCHAR, Fname VARCHAR, Lname VARCHAR); CREATE TABLE Sportsinfo (StuID VARCHAR)

Answer: [SQL] SELECT SUM(hoursperweek), SUM(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.Fname = "David" AND T2.Lname = "Shieber" [/SQL]


Question: Show total hours per week and number of games played for students under 20.

Context: CREATE TABLE Student (StuID VARCHAR, age INTEGER); CREATE TABLE Sportsinfo (StuID VARCHAR)

Answer: [SQL] SELECT SUM(hoursperweek), SUM(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20 [/SQL]


Question: How many students play video games?

Context: CREATE TABLE Plays_games (StuID VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT StuID) FROM Plays_games [/SQL]


Question: Show ids of students who don't play video game.

Context: CREATE TABLE Plays_games (StuID VARCHAR); CREATE TABLE Student (StuID VARCHAR)

Answer: [SQL] SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games [/SQL]


Question: Show ids of students who play video game and play sports.

Context: CREATE TABLE Plays_games (StuID VARCHAR); CREATE TABLE Sportsinfo (StuID VARCHAR)

Answer: [SQL] SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games [/SQL]


Question: Show all game ids and the number of hours played.

Context: CREATE TABLE Plays_games (gameid VARCHAR, hours_played INTEGER)

Answer: [SQL] SELECT gameid, SUM(hours_played) FROM Plays_games GROUP BY gameid [/SQL]


Question: Show all student ids and the number of hours played.

Context: CREATE TABLE Plays_games (Stuid VARCHAR, hours_played INTEGER)

Answer: [SQL] SELECT Stuid, SUM(hours_played) FROM Plays_games GROUP BY Stuid [/SQL]


Question: Show the game name that has most number of hours played.

Context: CREATE TABLE Plays_games (gameid VARCHAR); CREATE TABLE Video_games (gameid VARCHAR)

Answer: [SQL] SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY SUM(hours_played) DESC LIMIT 1 [/SQL]


Question: Show all game names played by at least 1000 hours.

Answer: [SQL] SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid HAVING SUM(hours_played) >= 1000 [/SQL]


Question: Show all game names played by Linda Smith

Context: CREATE TABLE Student (Stuid VARCHAR, Lname VARCHAR, Fname VARCHAR); CREATE TABLE Plays_games (gameid VARCHAR, Stuid VARCHAR); CREATE TABLE Video_games (gameid VARCHAR)

Answer: [SQL] SELECT Gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid JOIN Student AS T3 ON T3.Stuid = T1.Stuid WHERE T3.Lname = "Smith" AND T3.Fname = "Linda" [/SQL]


Question: Find the last and first name of students who are playing Football or Lacrosse.

Context: CREATE TABLE SportsInfo (StuID VARCHAR, SportName VARCHAR); CREATE TABLE Student (lname VARCHAR, fname VARCHAR, StuID VARCHAR)

Answer: [SQL] SELECT T2.lname, T2.fname FROM SportsInfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.SportName = "Football" OR T1.SportName = "Lacrosse" [/SQL]


Question: Find the first name and age of the students who are playing both Football and Lacrosse.

Context: CREATE TABLE Student (fname VARCHAR, age VARCHAR, StuID VARCHAR, SportName VARCHAR); CREATE TABLE Sportsinfo (fname VARCHAR, age VARCHAR, StuID VARCHAR, SportName VARCHAR)

Answer: [SQL] SELECT fname, age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse") [/SQL]


Question: Find the last name and gender of the students who are playing both Call of Destiny and Works of Widenius games.

Context: CREATE TABLE Plays_games (StuID VARCHAR, GameID VARCHAR); CREATE TABLE Student (lname VARCHAR, sex VARCHAR, StuID VARCHAR); CREATE TABLE Video_games (GameID VARCHAR, Gname VARCHAR)

Answer: [SQL] SELECT lname, sex FROM Student WHERE StuID IN (SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Call of Destiny" INTERSECT SELECT T1.StuID FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.GameID = T2.GameID WHERE T2.Gname = "Works of Widenius") [/SQL]


Question: Find the name of all customers.

Context: CREATE TABLE customers (customer_name VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers [/SQL]


Question: What is the average amount of items ordered in each order?

Context: CREATE TABLE order_items (order_quantity INTEGER)

Answer: [SQL] SELECT AVG(order_quantity) FROM order_items [/SQL]


Question: What are the names of customers who use payment method "Cash"?

Context: CREATE TABLE customers (customer_name VARCHAR, payment_method VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers WHERE payment_method = "Cash" [/SQL]


Question: Find the "date became customers" of the customers whose ID is between 10 and 20.

Context: CREATE TABLE customers (date_became_customer VARCHAR, customer_id INTEGER)

Answer: [SQL] SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20 [/SQL]


Question: Which payment method is used by most customers?

Context: CREATE TABLE customers (payment_method VARCHAR)

Answer: [SQL] SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What are the names of customers using the most popular payment method?

Answer: [SQL] SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: What are all the payment methods?

Answer: [SQL] SELECT DISTINCT payment_method FROM customers [/SQL]


Question: What are the details of all products?

Context: CREATE TABLE products (product_details VARCHAR)

Answer: [SQL] SELECT DISTINCT product_details FROM products [/SQL]


Question: Find the name of all customers whose name contains "Alex".

Answer: [SQL] SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%" [/SQL]


Question: Find the detail of products whose detail contains the word "Latte" or the word "Americano"

Answer: [SQL] SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%" [/SQL]


Question: What is the address content of the customer named "Maudie Kertzmann"?

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR); CREATE TABLE addresses (address_content VARCHAR, address_id VARCHAR)

Answer: [SQL] SELECT t3.address_content FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t1.customer_name = "Maudie Kertzmann" [/SQL]


Question: How many customers are living in city "Lake Geovannyton"?

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE addresses (address_id VARCHAR, city VARCHAR); CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.city = "Lake Geovannyton" [/SQL]


Question: Find the name of customers who are living in Colorado?

Context: CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE addresses (address_id VARCHAR, state_province_county VARCHAR)

Answer: [SQL] SELECT t1.customer_name FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.state_province_county = "Colorado" [/SQL]


Question: Find the list of cities that no customer is living in.

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR); CREATE TABLE addresses (city VARCHAR)

Answer: [SQL] SELECT city FROM addresses WHERE NOT city IN (SELECT DISTINCT t3.city FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id) [/SQL]


Question: Which city has the most customers living in?

Context: CREATE TABLE customers (customer_id VARCHAR); CREATE TABLE addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE customer_addresses (customer_id VARCHAR, address_id VARCHAR)

Answer: [SQL] SELECT t3.city FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id GROUP BY t3.city ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the city with post code 255.

Context: CREATE TABLE addresses (city VARCHAR, zip_postcode VARCHAR)

Answer: [SQL] SELECT city FROM addresses WHERE zip_postcode = 255 [/SQL]


Question: Find the state and country of all cities with post code starting with 4.

Context: CREATE TABLE addresses (state_province_county VARCHAR, country VARCHAR, zip_postcode VARCHAR)

Answer: [SQL] SELECT state_province_county, country FROM addresses WHERE zip_postcode LIKE "4%" [/SQL]


Question: List the countries having more than 4 addresses listed.

Context: CREATE TABLE addresses (country VARCHAR, address_id VARCHAR)

Answer: [SQL] SELECT country FROM addresses GROUP BY country HAVING COUNT(address_id) > 4 [/SQL]


Question: List all the contact channel codes that were used less than 5 times.

Context: CREATE TABLE customer_contact_channels (channel_code VARCHAR, customer_id VARCHAR)

Answer: [SQL] SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING COUNT(customer_id) < 5 [/SQL]


Question: Which contact channel has been used by the customer with name "Tillman Ernser"?

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE customer_contact_channels (customer_id VARCHAR)

Answer: [SQL] SELECT DISTINCT channel_code FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser" [/SQL]


Question: What is the "active to date" of the latest contact channel used by "Tillman Ernser"?

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE customer_contact_channels (active_to_date INTEGER, customer_id VARCHAR)

Answer: [SQL] SELECT MAX(t2.active_to_date) FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t1.customer_name = "Tillman Ernser" [/SQL]


Question: What is the average time span of contact channels in the database?

Context: CREATE TABLE customer_contact_channels (active_to_date VARCHAR, active_from_date VARCHAR)

Answer: [SQL] SELECT AVG(active_to_date - active_from_date) FROM customer_contact_channels [/SQL]


Question: What is the channel code and contact number of the customer contact channel that was active for the longest time?

Context: CREATE TABLE customer_contact_channels (channel_code VARCHAR, contact_number VARCHAR, active_to_date VARCHAR, active_from_date VARCHAR)

Answer: [SQL] SELECT channel_code, contact_number FROM customer_contact_channels WHERE active_to_date - active_from_date = (SELECT active_to_date - active_from_date FROM customer_contact_channels ORDER BY (active_to_date - active_from_date) DESC LIMIT 1) [/SQL]


Question: Find the name and active date of the customer that use email as the contact channel.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_contact_channels (active_from_date VARCHAR, customer_id VARCHAR, channel_code VARCHAR)

Answer: [SQL] SELECT t1.customer_name, t2.active_from_date FROM customers AS t1 JOIN customer_contact_channels AS t2 ON t1.customer_id = t2.customer_id WHERE t2.channel_code = 'Email' [/SQL]


Question: What is the name of the customer that made the order with the largest quantity?

Context: CREATE TABLE order_items (order_id VARCHAR, order_quantity INTEGER); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE order_items (order_quantity INTEGER); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t3.order_quantity = (SELECT MAX(order_quantity) FROM order_items) [/SQL]


Question: What is the name of the customer that has purchased the most items?

Context: CREATE TABLE order_items (order_id VARCHAR, order_quantity INTEGER); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY SUM(t3.order_quantity) DESC LIMIT 1 [/SQL]


Question: What is the payment method of the customer that has purchased the least quantity of items?

Context: CREATE TABLE order_items (order_id VARCHAR, order_quantity INTEGER); CREATE TABLE customers (payment_method VARCHAR, customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT t1.payment_method FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id GROUP BY t1.customer_name ORDER BY SUM(t3.order_quantity) LIMIT 1 [/SQL]


Question: How many types of products have Rodrick Heaney bought in total?

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE order_items (product_id VARCHAR, order_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT t3.product_id) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney" [/SQL]


Question: What is the total quantity of products purchased by "Rodrick Heaney"?

Context: CREATE TABLE customers (customer_id VARCHAR, customer_name VARCHAR); CREATE TABLE order_items (order_quantity INTEGER, order_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT SUM(t3.order_quantity) FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id WHERE t1.customer_name = "Rodrick Heaney" [/SQL]


Question: How many customers have at least one order with status "Cancelled"?

Context: CREATE TABLE customer_orders (customer_id VARCHAR, order_status VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT customer_id) FROM customer_orders WHERE order_status = "Cancelled" [/SQL]


Question: How many orders have detail "Second time"?

Context: CREATE TABLE customer_orders (order_details VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM customer_orders WHERE order_details = "Second time" [/SQL]


Question: Find the customer name and date of the orders that have the status "Delivered".

Context: CREATE TABLE customer_orders (order_date VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

Answer: [SQL] SELECT t1.customer_name, t2.order_date FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id WHERE order_status = "Delivered" [/SQL]


Question: What is the total number of products that are in orders with status "Cancelled"?

Context: CREATE TABLE customer_orders (order_id VARCHAR, order_status VARCHAR); CREATE TABLE order_items (order_quantity INTEGER, order_id VARCHAR)

Answer: [SQL] SELECT SUM(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_status = "Cancelled" [/SQL]


Question: Find the total amount of products ordered before 2018-03-17 07:13:53.

Context: CREATE TABLE customer_orders (order_id VARCHAR, order_date INTEGER); CREATE TABLE order_items (order_quantity INTEGER, order_id VARCHAR)

Answer: [SQL] SELECT SUM(t2.order_quantity) FROM customer_orders AS t1 JOIN order_items AS t2 ON t1.order_id = t2.order_id WHERE t1.order_date < "2018-03-17 07:13:53" [/SQL]


Question: Who made the latest order?

Context: CREATE TABLE customer_orders (customer_id VARCHAR, order_date VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

Answer: [SQL] SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.order_date DESC LIMIT 1 [/SQL]


Question: Which product has been ordered most number of times?

Context: CREATE TABLE products (product_details VARCHAR, product_id VARCHAR); CREATE TABLE order_items (product_id VARCHAR)

Answer: [SQL] SELECT t2.product_details FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the name and ID of the product whose total order quantity is the largest.

Context: CREATE TABLE order_items (product_id VARCHAR, order_quantity INTEGER); CREATE TABLE products (product_details VARCHAR, product_id VARCHAR)

Answer: [SQL] SELECT t2.product_details, t2.product_id FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY SUM(t1.order_quantity) LIMIT 1 [/SQL]


Question: Find all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona.

Context: CREATE TABLE addresses (address_content VARCHAR, city VARCHAR, state_province_county VARCHAR)

Answer: [SQL] SELECT address_content FROM addresses WHERE city = "East Julianaside" AND state_province_county = "Texas" UNION SELECT address_content FROM addresses WHERE city = "Gleasonmouth" AND state_province_county = "Arizona" [/SQL]


Question: Find the name of customers who did not pay with Cash.

Context: CREATE TABLE customers (customer_name VARCHAR, payment_method VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers WHERE payment_method <> 'Cash' [/SQL]


Question: Find the names of customers who never ordered product Latte.

Context: CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_details VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte' [/SQL]


Question: Find the names of customers who never placed an order.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR)

Answer: [SQL] SELECT customer_name FROM customers EXCEPT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id [/SQL]


Question: Find the names of customers who ordered both products Latte and Americano.

Context: CREATE TABLE products (product_id VARCHAR, product_details VARCHAR); CREATE TABLE order_items (order_id VARCHAR, product_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_orders (customer_id VARCHAR, order_id VARCHAR)

Answer: [SQL] SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Latte' INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN customer_orders AS t2 ON t1.customer_id = t2.customer_id JOIN order_items AS t3 ON t2.order_id = t3.order_id JOIN products AS t4 ON t3.product_id = t4.product_id WHERE t4.product_details = 'Americano' [/SQL]


Question: List the age of all music artists.

Context: CREATE TABLE artist (Age VARCHAR)

Answer: [SQL] SELECT Age FROM artist [/SQL]


Question: What is the average age of all artists?

Context: CREATE TABLE artist (Age INTEGER)

Answer: [SQL] SELECT AVG(Age) FROM artist [/SQL]


Question: What are the famous titles of the artist "Triumfall"?

Context: CREATE TABLE artist (Famous_Title VARCHAR, Artist VARCHAR)

Answer: [SQL] SELECT Famous_Title FROM artist WHERE Artist = "Triumfall" [/SQL]


Question: What are the distinct Famous release dates?

Context: CREATE TABLE artist (Famous_Release_date VARCHAR)

Answer: [SQL] SELECT DISTINCT (Famous_Release_date) FROM artist [/SQL]


Question: Return the dates of ceremony and the results of all music festivals

Context: CREATE TABLE music_festival (Date_of_ceremony VARCHAR, RESULT VARCHAR)

Answer: [SQL] SELECT Date_of_ceremony, RESULT FROM music_festival [/SQL]


Question: What are the category of music festivals with result "Awarded"?

Context: CREATE TABLE music_festival (Category VARCHAR, RESULT VARCHAR)

Answer: [SQL] SELECT Category FROM music_festival WHERE RESULT = "Awarded" [/SQL]


Question: What are the maximum and minimum week on top of all volumes?

Context: CREATE TABLE volume (Weeks_on_Top INTEGER)

Answer: [SQL] SELECT MAX(Weeks_on_Top), MIN(Weeks_on_Top) FROM volume [/SQL]


Question: What are the songs in volumes with more than 1 week on top?

Context: CREATE TABLE volume (Song VARCHAR, Weeks_on_Top INTEGER)

Answer: [SQL] SELECT Song FROM volume WHERE Weeks_on_Top > 1 [/SQL]


Question: Please list all songs in volumes in ascending alphabetical order.

Context: CREATE TABLE volume (Song VARCHAR)

Answer: [SQL] SELECT Song FROM volume ORDER BY Song [/SQL]


Question: How many distinct artists do the volumes associate to?

Context: CREATE TABLE volume (Artist_ID VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT Artist_ID) FROM volume [/SQL]


Question: Please show the date of ceremony of the volumes that last more than 2 weeks on top.

Context: CREATE TABLE music_festival (Date_of_ceremony VARCHAR, Volume VARCHAR); CREATE TABLE volume (Volume_ID VARCHAR, Weeks_on_Top INTEGER)

Answer: [SQL] SELECT T1.Date_of_ceremony FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T2.Weeks_on_Top > 2 [/SQL]


Question: Please show the songs that have result "nominated" at music festivals.

Context: CREATE TABLE volume (Song VARCHAR, Volume_ID VARCHAR); CREATE TABLE music_festival (Volume VARCHAR, Result VARCHAR)

Answer: [SQL] SELECT T2.Song FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T1.Result = "Nominated" [/SQL]


Question: What are the issue dates of volumes associated with the artist "Gorgoroth"?

Context: CREATE TABLE artist (Artist_ID VARCHAR, Artist VARCHAR); CREATE TABLE volume (Issue_Date VARCHAR, Artist_ID VARCHAR)

Answer: [SQL] SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = "Gorgoroth" [/SQL]


Question: What are the songs in volumes associated with the artist aged 32 or older?

Context: CREATE TABLE volume (Song VARCHAR, Artist_ID VARCHAR); CREATE TABLE artist (Artist_ID VARCHAR, age VARCHAR)

Answer: [SQL] SELECT T2.Song FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age >= 32 [/SQL]


Question: What is the average weeks on top of volumes associated with the artist aged 25 or younger?

Context: CREATE TABLE volume (Weeks_on_Top INTEGER, Artist_ID VARCHAR); CREATE TABLE artist (Artist_ID VARCHAR, age VARCHAR)

Answer: [SQL] SELECT AVG(T2.Weeks_on_Top) FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 25 [/SQL]


Question: What are the famous title of the artists associated with volumes with more than 2 weeks on top?

Context: CREATE TABLE artist (Famous_Title VARCHAR, Artist_ID VARCHAR); CREATE TABLE volume (Artist_ID VARCHAR, Weeks_on_Top INTEGER)

Answer: [SQL] SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2 [/SQL]


Question: Please list the age and famous title of artists in descending order of age.

Context: CREATE TABLE artist (Famous_Title VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Famous_Title, Age FROM artist ORDER BY Age DESC [/SQL]


Question: What is the famous release date of the artist with the oldest age?

Context: CREATE TABLE artist (Famous_Release_date VARCHAR, Age VARCHAR)

Answer: [SQL] SELECT Famous_Release_date FROM artist ORDER BY Age DESC LIMIT 1 [/SQL]


Question: Please show the categories of the music festivals and the count.

Context: CREATE TABLE music_festival (Category VARCHAR)

Answer: [SQL] SELECT Category, COUNT(*) FROM music_festival GROUP BY Category [/SQL]


Question: What is the most common result of the music festival?

Context: CREATE TABLE music_festival (RESULT VARCHAR)

Answer: [SQL] SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Please show the categories of the music festivals with count more than 1.

Answer: [SQL] SELECT Category FROM music_festival GROUP BY Category HAVING COUNT(*) > 1 [/SQL]


Question: What is the song in the volume with the maximum weeks on top?

Context: CREATE TABLE volume (Song VARCHAR, Weeks_on_Top VARCHAR)

Answer: [SQL] SELECT Song FROM volume ORDER BY Weeks_on_Top DESC LIMIT 1 [/SQL]


Question: Find the famous titles of artists that do not have any volume.

Context: CREATE TABLE volume (Famous_Title VARCHAR, Artist_ID VARCHAR); CREATE TABLE artist (Famous_Title VARCHAR, Artist_ID VARCHAR)

Answer: [SQL] SELECT Famous_Title FROM artist WHERE NOT Artist_ID IN (SELECT Artist_ID FROM volume) [/SQL]


Question: Show the famous titles of the artists with both volumes that lasted more than 2 weeks on top and volumes that lasted less than 2 weeks on top.

Answer: [SQL] SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top > 2 INTERSECT SELECT T1.Famous_Title FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T2.Weeks_on_Top < 2 [/SQL]


Question: What are the date of ceremony of music festivals with category "Best Song" and result "Awarded"?

Context: CREATE TABLE music_festival (Date_of_ceremony VARCHAR, Category VARCHAR, RESULT VARCHAR)

Answer: [SQL] SELECT Date_of_ceremony FROM music_festival WHERE Category = "Best Song" AND RESULT = "Awarded" [/SQL]


Question: What is the issue date of the volume with the minimum weeks on top?

Context: CREATE TABLE volume (Issue_Date VARCHAR, Weeks_on_Top VARCHAR)

Answer: [SQL] SELECT Issue_Date FROM volume ORDER BY Weeks_on_Top LIMIT 1 [/SQL]


Question: Please show the results of music festivals and the number of music festivals that have had each, ordered by this count.

Answer: [SQL] SELECT RESULT, COUNT(*) FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC [/SQL]


Question: What are the issue dates of volumes associated with the artist aged 23 or younger?

Context: CREATE TABLE volume (Artist_ID VARCHAR); CREATE TABLE artist (Artist_ID VARCHAR, age VARCHAR)

Answer: [SQL] SELECT Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 23 [/SQL]


Question: How many roller coasters are there?

Context: CREATE TABLE roller_coaster (Id VARCHAR)

Answer: [SQL] SELECT COUNT(*) FROM roller_coaster [/SQL]


Question: List the names of roller coasters by ascending order of length.

Context: CREATE TABLE roller_coaster (Name VARCHAR, LENGTH VARCHAR)

Answer: [SQL] SELECT Name FROM roller_coaster ORDER BY LENGTH [/SQL]


Question: What are the lengths and heights of roller coasters?

Context: CREATE TABLE roller_coaster (LENGTH VARCHAR, Height VARCHAR)

Answer: [SQL] SELECT LENGTH, Height FROM roller_coaster [/SQL]


Question: List the names of countries whose language is not "German".

Context: CREATE TABLE country (Name VARCHAR, Languages VARCHAR)

Answer: [SQL] SELECT Name FROM country WHERE Languages <> "German" [/SQL]


Question: Show the statuses of roller coasters longer than 3300 or higher than 100.

Context: CREATE TABLE roller_coaster (Status VARCHAR, LENGTH VARCHAR, Height VARCHAR)

Answer: [SQL] SELECT Status FROM roller_coaster WHERE LENGTH > 3300 OR Height > 100 [/SQL]


Question: What are the speeds of the longest roller coaster?

Context: CREATE TABLE roller_coaster (Speed VARCHAR, LENGTH VARCHAR)

Answer: [SQL] SELECT Speed FROM roller_coaster ORDER BY LENGTH DESC LIMIT 1 [/SQL]


Question: What is the average speed of roller coasters?

Context: CREATE TABLE roller_coaster (Speed INTEGER)

Answer: [SQL] SELECT AVG(Speed) FROM roller_coaster [/SQL]


Question: Show the different statuses and the numbers of roller coasters for each status.

Context: CREATE TABLE roller_coaster (Status VARCHAR)

Answer: [SQL] SELECT Status, COUNT(*) FROM roller_coaster GROUP BY Status [/SQL]


Question: Please show the most common status of roller coasters.

Answer: [SQL] SELECT Status FROM roller_coaster GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List the status shared by more than two roller coaster.

Answer: [SQL] SELECT Status FROM roller_coaster GROUP BY Status HAVING COUNT(*) > 2 [/SQL]


Question: Show the park of the roller coaster with the highest speed.

Context: CREATE TABLE roller_coaster (Park VARCHAR, Speed VARCHAR)

Answer: [SQL] SELECT Park FROM roller_coaster ORDER BY Speed DESC LIMIT 1 [/SQL]


Question: Show the names of roller coasters and names of country they are in.

Context: CREATE TABLE country (Name VARCHAR, Country_ID VARCHAR); CREATE TABLE roller_coaster (Name VARCHAR, Country_ID VARCHAR)

Answer: [SQL] SELECT T2.Name, T1.Name FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID [/SQL]


Question: Show the names of countries that have more than one roller coaster.

Context: CREATE TABLE roller_coaster (Country_ID VARCHAR); CREATE TABLE country (Name VARCHAR, Country_ID VARCHAR)

Answer: [SQL] SELECT T1.Name FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID GROUP BY T1.Name HAVING COUNT(*) > 1 [/SQL]


Question: Show the name and population of the country that has the highest roller coaster.

Context: CREATE TABLE roller_coaster (Country_ID VARCHAR, Height VARCHAR); CREATE TABLE country (Name VARCHAR, population VARCHAR, Country_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID ORDER BY T2.Height DESC LIMIT 1 [/SQL]


Question: Show the names of countries and the average speed of roller coasters from each country.

Context: CREATE TABLE roller_coaster (Speed INTEGER, Country_ID VARCHAR); CREATE TABLE country (Name VARCHAR, Country_ID VARCHAR)

Answer: [SQL] SELECT T1.Name, AVG(T2.Speed) FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID GROUP BY T1.Name [/SQL]


Question: How many countries do not have an roller coaster longer than 3000?

Context: CREATE TABLE country (country_id VARCHAR, LENGTH INTEGER); CREATE TABLE roller_coaster (country_id VARCHAR, LENGTH INTEGER)

Answer: [SQL] SELECT COUNT(*) FROM country WHERE NOT country_id IN (SELECT country_id FROM roller_coaster WHERE LENGTH > 3000) [/SQL]


Question: What are the country names, area and population which has both roller coasters with speed higher

Context: CREATE TABLE country (name VARCHAR, area VARCHAR, population VARCHAR, Country_ID VARCHAR); CREATE TABLE roller_coaster (Country_ID VARCHAR, speed INTEGER)

Answer: [SQL] SELECT T1.name, T1.area, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed > 60 INTERSECT SELECT T1.name, T1.area, T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID WHERE T2.speed < 55 [/SQL]


Question: How many different captain ranks are there?

Context: CREATE TABLE captain (rank VARCHAR)

Answer: [SQL] SELECT COUNT(DISTINCT rank) FROM captain [/SQL]


Question: How many captains are in each rank?

Context: CREATE TABLE captain (rank VARCHAR)

Answer: [SQL] SELECT COUNT(*), rank FROM captain GROUP BY rank [/SQL]


Question: How many captains with younger than 50 are in each rank?

Context: CREATE TABLE captain (rank VARCHAR, age INTEGER)

Answer: [SQL] SELECT COUNT(*), rank FROM captain WHERE age < 50 GROUP BY rank [/SQL]


Question: Sort all captain names by their ages from old to young.

Context: CREATE TABLE captain (name VARCHAR, age VARCHAR)

Answer: [SQL] SELECT name FROM captain ORDER BY age DESC [/SQL]


Question: Find the name, class and rank of all captains.

Context: CREATE TABLE captain (name VARCHAR, CLASS VARCHAR, rank VARCHAR)

Answer: [SQL] SELECT name, CLASS, rank FROM captain [/SQL]


Question: Which rank is the most common among captains?

Context: CREATE TABLE captain (rank VARCHAR)

Answer: [SQL] SELECT rank FROM captain GROUP BY rank ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Which classes have more than two captains?

Context: CREATE TABLE captain (CLASS VARCHAR)

Answer: [SQL] SELECT CLASS FROM captain GROUP BY CLASS HAVING COUNT(*) > 2 [/SQL]


Question: Find the name of captains whose rank are either Midshipman or Lieutenant.

Context: CREATE TABLE captain (name VARCHAR, rank VARCHAR)

Answer: [SQL] SELECT name FROM captain WHERE rank = 'Midshipman' OR rank = 'Lieutenant' [/SQL]


Question: What are the average and minimum age of captains in different class?

Context: CREATE TABLE captain (CLASS VARCHAR, age INTEGER)

Answer: [SQL] SELECT AVG(age), MIN(age), CLASS FROM captain GROUP BY CLASS [/SQL]


Question: Find the captain rank that has some captains in both Cutter and Armed schooner classes.

Context: CREATE TABLE captain (rank VARCHAR, CLASS VARCHAR)

Answer: [SQL] SELECT rank FROM captain WHERE CLASS = 'Cutter' INTERSECT SELECT rank FROM captain WHERE CLASS = 'Armed schooner' [/SQL]


Question: Find the captain rank that has no captain in Third-rate ship of the line class.

Answer: [SQL] SELECT rank FROM captain EXCEPT SELECT rank FROM captain WHERE CLASS = 'Third-rate ship of the line' [/SQL]


Question: What is the name of the youngest captain?

Answer: [SQL] SELECT name FROM captain ORDER BY age LIMIT 1 [/SQL]


Question: Find the name, type, and flag of the ship that is built in the most recent year.

Context: CREATE TABLE ship (name VARCHAR, TYPE VARCHAR, flag VARCHAR, built_year VARCHAR)

Answer: [SQL] SELECT name, TYPE, flag FROM ship ORDER BY built_year DESC LIMIT 1 [/SQL]


Question: Group by ships by flag, and return number of ships that have each flag.

Context: CREATE TABLE ship (flag VARCHAR)

Answer: [SQL] SELECT COUNT(*), flag FROM ship GROUP BY flag [/SQL]


Question: Which flag is most widely used among all ships?

Context: CREATE TABLE ship (flag VARCHAR)

Answer: [SQL] SELECT flag FROM ship GROUP BY flag ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: List all ship names in the order of built year and class.

Context: CREATE TABLE ship (name VARCHAR, built_year VARCHAR, CLASS VARCHAR)

Answer: [SQL] SELECT name FROM ship ORDER BY built_year, CLASS [/SQL]


Question: Find the ship type that are used by both ships with Panama and Malta flags.

Context: CREATE TABLE ship (TYPE VARCHAR, flag VARCHAR)

Answer: [SQL] SELECT TYPE FROM ship WHERE flag = 'Panama' INTERSECT SELECT TYPE FROM ship WHERE flag = 'Malta' [/SQL]


Question: In which year were most of ships built?

Context: CREATE TABLE ship (built_year VARCHAR)

Answer: [SQL] SELECT built_year FROM ship GROUP BY built_year ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the name of the ships that have more than one captain.

Context: CREATE TABLE captain (ship_id VARCHAR); CREATE TABLE ship (name VARCHAR, ship_id VARCHAR)

Answer: [SQL] SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id GROUP BY t2.ship_id HAVING COUNT(*) > 1 [/SQL]


Question: what are the names and classes of the ships that do not have any captain yet?

Context: CREATE TABLE ship (name VARCHAR, CLASS VARCHAR, ship_id VARCHAR); CREATE TABLE captain (name VARCHAR, CLASS VARCHAR, ship_id VARCHAR)

Answer: [SQL] SELECT name, CLASS FROM ship WHERE NOT ship_id IN (SELECT ship_id FROM captain) [/SQL]


Question: Find the name of the ship that is steered by the youngest captain.

Context: CREATE TABLE ship (name VARCHAR, ship_id VARCHAR); CREATE TABLE captain (ship_id VARCHAR, age VARCHAR)

Answer: [SQL] SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id ORDER BY t2.age LIMIT 1 [/SQL]


Question: Find the name and flag of ships that are not steered by any captain with Midshipman rank.

Context: CREATE TABLE captain (name VARCHAR, flag VARCHAR, ship_id VARCHAR, rank VARCHAR); CREATE TABLE ship (name VARCHAR, flag VARCHAR, ship_id VARCHAR, rank VARCHAR)

Answer: [SQL] SELECT name, flag FROM ship WHERE NOT ship_id IN (SELECT ship_id FROM captain WHERE rank = 'Midshipman') [/SQL]


Question: Find the name of the ships that are steered by both a captain with Midshipman rank and a captain with Lieutenant rank.

Context: CREATE TABLE ship (name VARCHAR, ship_id VARCHAR); CREATE TABLE captain (ship_id VARCHAR, rank VARCHAR)

Answer: [SQL] SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Midshipman' INTERSECT SELECT t1.name FROM ship AS t1 JOIN captain AS t2 ON t1.ship_id = t2.ship_id WHERE t2.rank = 'Lieutenant' [/SQL]


Question: What is id of the city that hosted events in the most recent year?

Context: CREATE TABLE hosting_city (host_city VARCHAR, YEAR VARCHAR)

Answer: [SQL] SELECT host_city FROM hosting_city ORDER BY YEAR DESC LIMIT 1 [/SQL]


Question: Find the match ids of the cities that hosted competition "1994 FIFA World Cup qualification"?

Context: CREATE TABLE MATCH (match_id VARCHAR, competition VARCHAR)

Answer: [SQL] SELECT match_id FROM MATCH WHERE competition = "1994 FIFA World Cup qualification" [/SQL]


Question: Find the cities which were once a host city after 2010?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR, year INTEGER)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T2.year > 2010 [/SQL]


Question: Which city has hosted the most events?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY T2.host_city ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: What is the venue of the competition "1994 FIFA World Cup qualification" hosted by "Nanjing ( Jiangsu )"?

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE MATCH (venue VARCHAR, match_id VARCHAR, competition VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR, match_id VARCHAR)

Answer: [SQL] SELECT T3.venue FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN MATCH AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification" [/SQL]


Question: Give me the temperature of Shanghai in January.

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE temperature (Jan VARCHAR, city_id VARCHAR)

Answer: [SQL] SELECT T2.Jan FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T1.city = "Shanghai" [/SQL]


Question: What is the host year of city "Taizhou ( Zhejiang )"?

Context: CREATE TABLE city (city_id VARCHAR, city VARCHAR); CREATE TABLE hosting_city (year VARCHAR, host_city VARCHAR)

Answer: [SQL] SELECT T2.year FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city WHERE T1.city = "Taizhou ( Zhejiang )" [/SQL]


Question: Which three cities have the largest regional population?

Context: CREATE TABLE city (city VARCHAR, regional_population VARCHAR)

Answer: [SQL] SELECT city FROM city ORDER BY regional_population DESC LIMIT 3 [/SQL]


Question: Which city has the lowest GDP? Please list the city name and its GDP.

Context: CREATE TABLE city (city VARCHAR, GDP VARCHAR)

Answer: [SQL] SELECT city, GDP FROM city ORDER BY GDP LIMIT 1 [/SQL]


Question: Which city has the highest temperature in February?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Feb VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id ORDER BY T2.Feb DESC LIMIT 1 [/SQL]


Question: Give me a list of cities whose temperature in March is lower than that in July or higher than that in Oct?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar VARCHAR, Jul VARCHAR, Oct VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Jul OR T2.Mar > T2.Oct [/SQL]


Question: Give me a list of cities whose temperature in Mar is lower than that in July and which have also served as host cities?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar INTEGER, Jul VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Jul INTERSECT SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city [/SQL]


Question: Give me a list of cities whose temperature in Mar is lower than that in Dec and which have never been host cities.

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Mar INTEGER, Dec VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Mar < T2.Dec EXCEPT SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city [/SQL]


Question: Give me a list of cities whose temperature in Feb is higher than that in Jun or cities that were once host cities?

Context: CREATE TABLE city (city VARCHAR, city_id VARCHAR); CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE temperature (city_id VARCHAR, Feb INTEGER, Jun VARCHAR)

Answer: [SQL] SELECT T1.city FROM city AS T1 JOIN temperature AS T2 ON T1.city_id = T2.city_id WHERE T2.Feb > T2.Jun UNION SELECT T3.city FROM city AS T3 JOIN hosting_city AS T4 ON T3.city_id = T4.host_city [/SQL]


Question: Please give me a list of cities whose regional population is over 10000000.

Context: CREATE TABLE city (city VARCHAR, regional_population INTEGER)

Answer: [SQL] SELECT city FROM city WHERE regional_population > 10000000 [/SQL]


Question: Please give me a list of cities whose regional population is over 8000000 or under 5000000.

Answer: [SQL] SELECT city FROM city WHERE regional_population > 10000000 UNION SELECT city FROM city WHERE regional_population < 5000000 [/SQL]


Question: Find the number of matches in different competitions.

Context: CREATE TABLE MATCH (Competition VARCHAR)

Answer: [SQL] SELECT COUNT(*), Competition FROM MATCH GROUP BY Competition [/SQL]


Question: List venues of all matches in the order of their dates starting from the most recent one.

Context: CREATE TABLE MATCH (venue VARCHAR, date VARCHAR)

Answer: [SQL] SELECT venue FROM MATCH ORDER BY date DESC [/SQL]


Question: what is the GDP of the city with the largest population.

Context: CREATE TABLE city (gdp VARCHAR, Regional_Population VARCHAR)

Answer: [SQL] SELECT gdp FROM city ORDER BY Regional_Population DESC LIMIT 1 [/SQL]


Question: What are the GDP and population of the city that already served as a host more than once?

Context: CREATE TABLE hosting_city (host_city VARCHAR); CREATE TABLE city (city_id VARCHAR)

Answer: [SQL] SELECT t1.gdp, t1.Regional_Population FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city GROUP BY t2.Host_City HAVING COUNT(*) > 1 [/SQL]


Question: List every individual's first name, middle name and last name in alphabetical order by last name.

Context: CREATE TABLE individuals (individual_first_name VARCHAR, individual_middle_name VARCHAR, individual_last_name VARCHAR)

Answer: [SQL] SELECT individual_first_name, individual_middle_name, individual_last_name FROM individuals ORDER BY individual_last_name [/SQL]


Question: List all the types of forms.

Context: CREATE TABLE forms (form_type_code VARCHAR)

Answer: [SQL] SELECT DISTINCT form_type_code FROM forms [/SQL]


Question: Find the name of the most popular party form.

Context: CREATE TABLE party_forms (form_id VARCHAR); CREATE TABLE forms (form_name VARCHAR, form_id VARCHAR)

Answer: [SQL] SELECT t1.form_name FROM forms AS t1 JOIN party_forms AS t2 ON t1.form_id = t2.form_id GROUP BY t2.form_id ORDER BY COUNT(*) DESC LIMIT 1 [/SQL]


Question: Find the payment method and phone of the party with email "enrico09@example.com".

Context: CREATE TABLE parties (payment_method_code VARCHAR, party_phone VARCHAR, party_email VARCHAR)

Answer: [SQL] SELECT payment_method_code, party_phone FROM parties WHERE party_email = "enrico09@example.com" [/SQL]


Question: Find the emails of parties with the most popular party form.

Context: CREATE TABLE party_forms (form_id VARCHAR); CREATE TABLE parties (party_email VARCHAR, party_id VARCHAR); CREATE TABLE party_forms (party_id VARCHAR, form_id VARCHAR)

Answer: [SQL] SELECT t1.party_email FROM parties AS t1 JOIN party_forms AS t2 ON t1.party_id = t2.party_id WHERE t2.form_id = (SELECT form_id FROM party_forms GROUP BY form_id ORDER BY COUNT(*) DESC LIMIT 1) [/SQL]


Question: List all the name of organizations in order of the date formed.

Context: CREATE TABLE organizations (organization_name VARCHAR, date_formed VARCHAR)

Answer: [SQL] SELECT organization_name FROM organizations ORDER BY date_formed [/SQL]


Question: Find the name of the youngest organization.

Answer: [SQL] SELECT organization_name FROM organizations ORDER BY date_formed DESC LIMIT 1 [/SQL]