Question: How many stadiums does each country have?

Context: CREATE TABLE stadium (country VARCHAR)

SELECT country, COUNT(*) FROM stadium GROUP BY country


Question: Which countries do not have a stadium that was opened after 2006?

Context: CREATE TABLE stadium (country VARCHAR, opening_year INTEGER)

SELECT country FROM stadium EXCEPT SELECT country FROM stadium WHERE opening_year > 2006


Question: How many stadiums are not in country "Russia"?

Context: CREATE TABLE stadium (country VARCHAR)

SELECT COUNT(*) FROM stadium WHERE country <> 'Russia'


Question: Find the names of all swimmers, sorted by their 100 meter scores in ascending order.

Context: CREATE TABLE swimmer (name VARCHAR, meter_100 VARCHAR)

SELECT name FROM swimmer ORDER BY meter_100


Question: How many different countries are all the swimmers from?

Context: CREATE TABLE swimmer (nationality VARCHAR)

SELECT COUNT(DISTINCT nationality) FROM swimmer


Question: List countries that have more than one swimmer.

SELECT nationality, COUNT(*) FROM swimmer GROUP BY nationality HAVING COUNT(*) > 1


Question: Find all 200 meter and 300 meter results of swimmers with nationality "Australia".

Context: CREATE TABLE swimmer (meter_200 VARCHAR, meter_300 VARCHAR, nationality VARCHAR)

SELECT meter_200, meter_300 FROM swimmer WHERE nationality = 'Australia'


Question: Find the names of swimmers who has a result of "win".

Context: CREATE TABLE record (swimmer_id VARCHAR); CREATE TABLE swimmer (name VARCHAR, id VARCHAR)

SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win'


Question: What is the name of the stadium which held the most events?

Context: CREATE TABLE stadium (name VARCHAR, id VARCHAR); CREATE TABLE event (stadium_id VARCHAR)

SELECT t1.name FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name and capacity of the stadium where the event named "World Junior" happened.

Context: CREATE TABLE event (stadium_id VARCHAR, name VARCHAR); CREATE TABLE stadium (name VARCHAR, capacity VARCHAR, id VARCHAR)

SELECT t1.name, t1.capacity FROM stadium AS t1 JOIN event AS t2 ON t1.id = t2.stadium_id WHERE t2.name = 'World Junior'


Question: Find the names of stadiums which have never had any event.

Context: CREATE TABLE stadium (name VARCHAR, id VARCHAR, stadium_id VARCHAR); CREATE TABLE event (name VARCHAR, id VARCHAR, stadium_id VARCHAR)

SELECT name FROM stadium WHERE NOT id IN (SELECT stadium_id FROM event)


Question: Find the name of the swimmer who has the most records.

SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the swimmer who has at least 2 records.

SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id GROUP BY t2.swimmer_id HAVING COUNT(*) >= 2


Question: Find the name and nationality of the swimmer who has won (i.e., has a result of "win") more than 1 time.

Context: CREATE TABLE record (swimmer_id VARCHAR); CREATE TABLE swimmer (name VARCHAR, nationality VARCHAR, id VARCHAR)

SELECT t1.name, t1.nationality FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' GROUP BY t2.swimmer_id HAVING COUNT(*) > 1


Question: Find the names of the swimmers who have no record.

Context: CREATE TABLE swimmer (name VARCHAR, id VARCHAR, swimmer_id VARCHAR); CREATE TABLE record (name VARCHAR, id VARCHAR, swimmer_id VARCHAR)

SELECT name FROM swimmer WHERE NOT id IN (SELECT swimmer_id FROM record)


Question: Find the names of the swimmers who have both "win" and "loss" results in the record.

SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Win' INTERSECT SELECT t1.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id WHERE RESULT = 'Loss'


Question: Find the names of stadiums that some Australian swimmers have been to.

Context: CREATE TABLE swimmer (id VARCHAR, nationality VARCHAR); CREATE TABLE record (swimmer_id VARCHAR, event_id VARCHAR); CREATE TABLE stadium (name VARCHAR, id VARCHAR); CREATE TABLE event (id VARCHAR, stadium_id VARCHAR)

SELECT t4.name FROM swimmer AS t1 JOIN record AS t2 ON t1.id = t2.swimmer_id JOIN event AS t3 ON t2.event_id = t3.id JOIN stadium AS t4 ON t4.id = t3.stadium_id WHERE t1.nationality = 'Australia'


Question: Find the names of stadiums that the most swimmers have been to.

Context: CREATE TABLE record (event_id VARCHAR); CREATE TABLE stadium (name VARCHAR, id VARCHAR); CREATE TABLE event (stadium_id VARCHAR, id VARCHAR)

SELECT t3.name FROM record AS t1 JOIN event AS t2 ON t1.event_id = t2.id JOIN stadium AS t3 ON t3.id = t2.stadium_id GROUP BY t2.stadium_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find all details for each swimmer.

Context: CREATE TABLE swimmer (Id VARCHAR)


Question: What is the average capacity of the stadiums that were opened in year 2005?

Context: CREATE TABLE stadium (capacity INTEGER, opening_year VARCHAR)

SELECT AVG(capacity) FROM stadium WHERE opening_year = 2005


Question: How many railways are there?

Context: CREATE TABLE railway (Id VARCHAR)


Question: List the builders of railways in ascending alphabetical order.

Context: CREATE TABLE railway (Builder VARCHAR)

SELECT Builder FROM railway ORDER BY Builder


Question: List the wheels and locations of the railways.

Context: CREATE TABLE railway (Wheels VARCHAR, LOCATION VARCHAR)


Question: What is the maximum level of managers in countries that are not "Australia"?

Context: CREATE TABLE manager (LEVEL INTEGER, Country VARCHAR)

SELECT MAX(LEVEL) FROM manager WHERE Country <> "Australia	"


Question: What is the average age for all managers?

Context: CREATE TABLE manager (Age INTEGER)


Question: What are the names of managers in ascending order of level?

Context: CREATE TABLE manager (Name VARCHAR, LEVEL VARCHAR)


Question: What are the names and arrival times of trains?

Context: CREATE TABLE train (Name VARCHAR, Arrival VARCHAR)


Question: What is the name of the oldest manager?

Context: CREATE TABLE manager (Name VARCHAR, Age VARCHAR)

SELECT Name FROM manager ORDER BY Age DESC LIMIT 1


Question: Show the names of trains and locations of railways they are in.

Context: CREATE TABLE railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Name VARCHAR, Railway_ID VARCHAR)

SELECT T2.Name, T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID


Question: Show the builder of railways associated with the trains named "Andaman Exp".

Context: CREATE TABLE railway (Builder VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR, Name VARCHAR)

SELECT T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID WHERE T2.Name = "Andaman Exp"


Question: Show id and location of railways that are associated with more than one train.

Context: CREATE TABLE railway (Location VARCHAR, Railway_ID VARCHAR); CREATE TABLE train (Railway_ID VARCHAR)

SELECT T2.Railway_ID, T1.Location FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID HAVING COUNT(*) > 1


Question: Show the id and builder of the railway that are associated with the most trains.

Context: CREATE TABLE train (Railway_ID VARCHAR); CREATE TABLE railway (Builder VARCHAR, Railway_ID VARCHAR)

SELECT T2.Railway_ID, T1.Builder FROM railway AS T1 JOIN train AS T2 ON T1.Railway_ID = T2.Railway_ID GROUP BY T2.Railway_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: Show different builders of railways, along with the corresponding number of railways using each builder.

Context: CREATE TABLE railway (Builder VARCHAR)

SELECT Builder, COUNT(*) FROM railway GROUP BY Builder


Question: Show the most common builder of railways.

Context: CREATE TABLE railway (Builder VARCHAR)

SELECT Builder FROM railway GROUP BY Builder ORDER BY COUNT(*) DESC LIMIT 1


Question: Show different locations of railways along with the corresponding number of railways at each location.

Context: CREATE TABLE railway (LOCATION VARCHAR)

SELECT LOCATION, COUNT(*) FROM railway GROUP BY LOCATION


Question: Show the locations that have more than one railways.

Context: CREATE TABLE railway (LOCATION VARCHAR)

SELECT LOCATION FROM railway GROUP BY LOCATION HAVING COUNT(*) > 1


Question: List the object number of railways that do not have any trains.

Context: CREATE TABLE train (ObjectNumber VARCHAR, Railway_ID VARCHAR); CREATE TABLE railway (ObjectNumber VARCHAR, Railway_ID VARCHAR)

SELECT ObjectNumber FROM railway WHERE NOT Railway_ID IN (SELECT Railway_ID FROM train)


Question: Show the countries that have both managers of age above 50 and managers of age below 46.

Context: CREATE TABLE manager (Country VARCHAR, Age INTEGER)

SELECT Country FROM manager WHERE Age > 50 INTERSECT SELECT Country FROM manager WHERE Age < 46


Question: Show the distinct countries of managers.

Context: CREATE TABLE manager (Country VARCHAR)


Question: Show the working years of managers in descending order of their level.

Context: CREATE TABLE manager (Working_year_starts VARCHAR, LEVEL VARCHAR)

SELECT Working_year_starts FROM manager ORDER BY LEVEL DESC


Question: Show the countries that have managers of age above 50 or below 46.

Context: CREATE TABLE manager (Country VARCHAR, Age VARCHAR)

SELECT Country FROM manager WHERE Age > 50 OR Age < 46


Question: How many addresses are there in country USA?

Context: CREATE TABLE addresses (country VARCHAR)

SELECT COUNT(*) FROM addresses WHERE country = 'USA'


Question: Show all distinct cities in the address record.

Context: CREATE TABLE addresses (city VARCHAR)


Question: Show each state and the number of addresses in each state.

Context: CREATE TABLE addresses (state_province_county VARCHAR)

SELECT state_province_county, COUNT(*) FROM addresses GROUP BY state_province_county


Question: Show names and phones of customers who do not have address information.

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

SELECT customer_name, customer_phone FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM customer_address_history)


Question: Show the name of the customer who has the most orders.

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

SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the product type codes which have at least two products.

Context: CREATE TABLE products (product_type_code VARCHAR)

SELECT product_type_code FROM products GROUP BY product_type_code HAVING COUNT(*) >= 2


Question: Show the names of customers who have both an order in completed status and an order in part status.

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

SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Completed' INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = 'Part'


Question: Show the name, phone, and payment method code for all customers in descending order of customer number.

Context: CREATE TABLE customers (customer_name VARCHAR, customer_phone VARCHAR, payment_method_code VARCHAR, customer_number VARCHAR)

SELECT customer_name, customer_phone, payment_method_code FROM customers ORDER BY customer_number DESC


Question: Show the product name and total order quantity for each product.

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

SELECT T1.product_name, SUM(T2.order_quantity) FROM products AS T1 JOIN order_items AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_id


Question: Show the minimum, maximum, average price for all products.

Context: CREATE TABLE products (product_price INTEGER)

SELECT MIN(product_price), MAX(product_price), AVG(product_price) FROM products


Question: How many products have a price higher than the average?

SELECT COUNT(*) FROM products WHERE product_price > (SELECT AVG(product_price) FROM products)


Question: Show the customer name, customer address city, date from, and date to for each customer address history.

Context: CREATE TABLE addresses (city VARCHAR, address_id VARCHAR); CREATE TABLE customers (customer_name VARCHAR, customer_id VARCHAR); CREATE TABLE customer_address_history (date_from VARCHAR, date_to VARCHAR, customer_id VARCHAR, address_id VARCHAR)

SELECT T2.customer_name, T3.city, T1.date_from, T1.date_to FROM customer_address_history AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id JOIN addresses AS T3 ON T1.address_id = T3.address_id


Question: Show the names of customers who use Credit Card payment method and have more than 2 orders.

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

SELECT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.payment_method_code = 'Credit Card' GROUP BY T1.customer_id HAVING COUNT(*) > 2


Question: What are the name and phone of the customer with the most ordered product quantity?

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

SELECT T1.customer_name, T1.customer_phone FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T3.order_id = T2.order_id GROUP BY T1.customer_id ORDER BY SUM(T3.order_quantity) DESC LIMIT 1


Question: Show the product type and name for the products with price higher than 1000 or lower than 500.

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

SELECT product_type_code, product_name FROM products WHERE product_price > 1000 OR product_price < 500


Question: Find the name of dorms only for female (F gender).

Context: CREATE TABLE dorm (dorm_name VARCHAR, gender VARCHAR)

SELECT dorm_name FROM dorm WHERE gender = 'F'


Question: Find the name of dorms that can accommodate more than 300 students.

Context: CREATE TABLE dorm (dorm_name VARCHAR, student_capacity INTEGER)

SELECT dorm_name FROM dorm WHERE student_capacity > 300


Question: How many female students (sex is F) whose age is below 25?

Context: CREATE TABLE student (sex VARCHAR, age VARCHAR)

SELECT COUNT(*) FROM student WHERE sex = 'F' AND age < 25


Question: Find the first name of students who is older than 20.

Context: CREATE TABLE student (fname VARCHAR, age INTEGER)

SELECT fname FROM student WHERE age > 20


Question: Find the first name of students living in city PHL whose age is between 20 and 25.

Context: CREATE TABLE student (fname VARCHAR, city_code VARCHAR, age VARCHAR)

SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25


Question: How many dorms are there?

Context: CREATE TABLE dorm (Id VARCHAR)


Question: Find the number of distinct amenities.

Context: CREATE TABLE dorm_amenity (Id VARCHAR)


Question: Find the total capacity of all dorms.

Context: CREATE TABLE dorm (student_capacity INTEGER)


Question: Find the average age of all students living in the each city.

Context: CREATE TABLE student (city_code VARCHAR, age INTEGER)

SELECT AVG(age), city_code FROM student GROUP BY city_code


Question: Find the average and total capacity of dorms for the students with gender X.

Context: CREATE TABLE dorm (student_capacity INTEGER, gender VARCHAR)

SELECT AVG(student_capacity), SUM(student_capacity) FROM dorm WHERE gender = 'X'


Question: Find the number of dorms that have some amenity.

Context: CREATE TABLE has_amenity (dormid VARCHAR)

SELECT COUNT(DISTINCT dormid) FROM has_amenity


Question: Find the name of dorms that do not have any amenity

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

SELECT dorm_name FROM dorm WHERE NOT dormid IN (SELECT dormid FROM has_amenity)


Question: Find the number of distinct gender for dorms.

Context: CREATE TABLE dorm (gender VARCHAR)


Question: Find the capacity and gender type of the dorm whose name has substring ‘Donor’.

Context: CREATE TABLE dorm (student_capacity VARCHAR, gender VARCHAR, dorm_name VARCHAR)

SELECT student_capacity, gender FROM dorm WHERE dorm_name LIKE '%Donor%'


Question: Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100.

Context: CREATE TABLE dorm (dorm_name VARCHAR, gender VARCHAR, student_capacity VARCHAR)

SELECT dorm_name, gender FROM dorm WHERE student_capacity > 300 OR student_capacity < 100


Question: Find the numbers of different majors and cities.

Context: CREATE TABLE student (major VARCHAR, city_code VARCHAR)

SELECT COUNT(DISTINCT major), COUNT(DISTINCT city_code) FROM student


Question: Find the name of dorms which have both TV Lounge and Study Room as amenities.

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

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' INTERSECT 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 = 'Study Room'


Question: Find the name of dorms which have TV Lounge but no Study Room as amenity.

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' 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 = 'Study Room'


Question: Find the last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20.

Context: CREATE TABLE student (lname VARCHAR, sex VARCHAR, city_code VARCHAR, age VARCHAR)

SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20


Question: Find the name of the dorm with the largest capacity.

Context: CREATE TABLE dorm (dorm_name VARCHAR, student_capacity VARCHAR)

SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1


Question: List in alphabetic order all different amenities.

Context: CREATE TABLE dorm_amenity (amenity_name VARCHAR)

SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name


Question: Find the code of city where most of students are living in.

Context: CREATE TABLE student (city_code VARCHAR)

SELECT city_code FROM student GROUP BY city_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the first and last name of students whose age is younger than the average age.

Context: CREATE TABLE student (fname VARCHAR, lname VARCHAR, age INTEGER)

SELECT fname, lname FROM student WHERE age < (SELECT AVG(age) FROM student)


Question: List the first and last name of students who are not living in the city with code HKG, and sorted the results by their ages.

Context: CREATE TABLE student (fname VARCHAR, lname VARCHAR, city_code VARCHAR, age VARCHAR)

SELECT fname, lname FROM student WHERE city_code <> 'HKG' ORDER BY age


Question: List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.

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

SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name


Question: Find the number of dorms and total capacity for each gender.

Context: CREATE TABLE dorm (gender VARCHAR, student_capacity INTEGER)

SELECT COUNT(*), SUM(student_capacity), gender FROM dorm GROUP BY gender


Question: Find the average and oldest age for students with different sex.

Context: CREATE TABLE student (sex VARCHAR, age INTEGER)

SELECT AVG(age), MAX(age), sex FROM student GROUP BY sex


Question: Find the number of students in each major.

Context: CREATE TABLE student (major VARCHAR)

SELECT COUNT(*), major FROM student GROUP BY major


Question: Find the number and average age of students living in each city.

Context: CREATE TABLE student (city_code VARCHAR, age INTEGER)

SELECT COUNT(*), AVG(age), city_code FROM student GROUP BY city_code


Question: Find the average age and number of male students (with sex M) from each city.

Context: CREATE TABLE student (city_code VARCHAR, age INTEGER, sex VARCHAR)

SELECT COUNT(*), AVG(age), city_code FROM student WHERE sex = 'M' GROUP BY city_code


Question: Find the number of students for the cities where have more than one student.

SELECT COUNT(*), city_code FROM student GROUP BY city_code HAVING COUNT(*) > 1


Question: Find the first and last name of students who are not in the largest major.

Context: CREATE TABLE student (fname VARCHAR, lname VARCHAR, major VARCHAR)

SELECT fname, lname FROM student WHERE major <> (SELECT major FROM student GROUP BY major ORDER BY COUNT(*) DESC LIMIT 1)


Question: Find the number of students whose age is older than the average age for each gender.

SELECT COUNT(*), sex FROM student WHERE age > (SELECT AVG(age) FROM student) GROUP BY sex


Question: Find the average age of students living in each dorm and the name of dorm.

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

SELECT AVG(T1.age), 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 GROUP BY T3.dorm_name


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)

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


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)

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


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)

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'


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)

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)


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)

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'


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)

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'


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)

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'


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

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


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)

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


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)

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)


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)

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


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)

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'


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)

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')


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)

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')


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)

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'


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)

SELECT email_address, phone_number FROM customers ORDER BY email_address, phone_number


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)

SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY COUNT(*) LIMIT 1


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)

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


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)

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


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)

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


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)

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


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)

SELECT email_address, phone_number FROM customers WHERE NOT customer_id IN (SELECT customer_id FROM complaints)


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

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

SELECT phone_number FROM customers UNION SELECT phone_number FROM staff


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

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

SELECT product_description FROM products WHERE product_name = "Chocolate"


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)

SELECT product_name, product_category_code FROM products ORDER BY product_price DESC LIMIT 1


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)

SELECT product_price FROM products WHERE NOT product_id IN (SELECT product_id FROM complaints)


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

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

SELECT AVG(product_price), product_category_code FROM products GROUP BY product_category_code


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)

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


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

Context: CREATE TABLE complaints (complaint_status_code VARCHAR)

SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING COUNT(*) > 3


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

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

SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"


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

Context: CREATE TABLE customers (customer_type_code VARCHAR)

SELECT COUNT(*) FROM customers GROUP BY customer_type_code ORDER BY COUNT(*) DESC LIMIT 1


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)

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


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

Context: CREATE TABLE complaints (complaint_type_code VARCHAR)

SELECT COUNT(DISTINCT complaint_type_code) FROM complaints


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)

SELECT address_line_1, address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"


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)

SELECT complaint_status_code, COUNT(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code


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)

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


Question: Which state has the most customers?

Context: CREATE TABLE customers (state VARCHAR)

SELECT state FROM customers GROUP BY state ORDER BY COUNT(*) LIMIT 1


Question: How many submissions are there?

Context: CREATE TABLE submission (Id VARCHAR)


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

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

SELECT Author FROM submission ORDER BY Scores


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

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


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

SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"


Question: What is the average score of submissions?

Context: CREATE TABLE submission (Scores INTEGER)


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

SELECT Author FROM submission ORDER BY Scores DESC LIMIT 1


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

Context: CREATE TABLE submission (College VARCHAR)

SELECT College, COUNT(*) FROM submission GROUP BY College


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

SELECT College FROM submission GROUP BY College ORDER BY COUNT(*) DESC LIMIT 1


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)

SELECT College FROM submission WHERE Scores > 90 INTERSECT SELECT College FROM submission WHERE Scores < 80


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)

SELECT T2.Author, T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID


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)

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


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)

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


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)

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


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

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

SELECT Date, Venue FROM workshop ORDER BY Venue


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)

SELECT Author FROM submission WHERE NOT Submission_ID IN (SELECT Submission_ID FROM acceptance)


Question: Find the number of investors in total.

Context: CREATE TABLE INVESTORS (Id VARCHAR)


Question: Show all investor details.

Context: CREATE TABLE INVESTORS (Investor_details VARCHAR)


Question: Show all distinct lot details.

Context: CREATE TABLE LOTS (lot_details VARCHAR)


Question: Show the maximum amount of transaction.

Context: CREATE TABLE TRANSACTIONS (amount_of_transaction INTEGER)

SELECT MAX(amount_of_transaction) FROM TRANSACTIONS


Question: Show all date and share count of transactions.

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

SELECT date_of_transaction, share_count FROM TRANSACTIONS


Question: What is the total share of transactions?

Context: CREATE TABLE TRANSACTIONS (share_count INTEGER)

SELECT SUM(share_count) FROM TRANSACTIONS


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

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

SELECT transaction_id FROM TRANSACTIONS WHERE transaction_type_code = 'PUR'


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

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

SELECT date_of_transaction FROM TRANSACTIONS WHERE transaction_type_code = "SALE"


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

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

SELECT AVG(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "SALE"


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

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

SELECT transaction_type_description FROM Ref_Transaction_Types WHERE transaction_type_code = "PUR"


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)

SELECT MIN(amount_of_transaction) FROM TRANSACTIONS WHERE transaction_type_code = "PUR" AND share_count > 50


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)

SELECT MAX(share_count) FROM TRANSACTIONS WHERE amount_of_transaction < 10000


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)

SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count > 100 OR amount_of_transaction > 1000


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)

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


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)

SELECT T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.share_count > 100


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

Context: CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR)

SELECT COUNT(DISTINCT transaction_type_code) FROM TRANSACTIONS


Question: Return the lot details and investor ids.

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

SELECT lot_details, investor_id FROM LOTS


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)

SELECT T2.lot_details FROM INVESTORS AS T1 JOIN LOTS AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l"


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)

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


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)

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


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)

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


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)

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"


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

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

SELECT transaction_type_code, AVG(amount_of_transaction) FROM TRANSACTIONS GROUP BY transaction_type_code


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

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

SELECT transaction_type_code, MAX(share_count), MIN(share_count) FROM TRANSACTIONS GROUP BY transaction_type_code


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

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

SELECT investor_id, AVG(share_count) FROM TRANSACTIONS GROUP BY investor_id


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

SELECT investor_id, AVG(share_count) FROM TRANSACTIONS GROUP BY investor_id ORDER BY AVG(share_count)


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

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

SELECT investor_id, AVG(amount_of_transaction) FROM TRANSACTIONS GROUP BY investor_id


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)

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


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

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)


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)

SELECT investor_id, COUNT(*) FROM TRANSACTIONS WHERE transaction_type_code = "SALE" GROUP BY investor_id


Question: Show the number of transactions for different investors.

Context: CREATE TABLE TRANSACTIONS (investor_id VARCHAR)

SELECT investor_id, COUNT(*) FROM TRANSACTIONS GROUP BY investor_id


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

SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) LIMIT 1


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

SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1


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)

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


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)

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


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

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


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)

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


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)

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


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)

SELECT date_of_transaction FROM TRANSACTIONS WHERE share_count >= 100 OR amount_of_transaction >= 100


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)

SELECT sales_details FROM sales UNION SELECT purchase_details FROM purchases


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)

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


Question: How many available hotels are there in total?

Context: CREATE TABLE HOTELS (Id VARCHAR)


Question: What are the price ranges of hotels?

Context: CREATE TABLE HOTELS (price_range VARCHAR)


Question: Show all distinct location names.

Context: CREATE TABLE LOCATIONS (Location_Name VARCHAR)

SELECT DISTINCT Location_Name FROM LOCATIONS


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

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


Question: Show details of all visitors.

Context: CREATE TABLE VISITORS (Tourist_Details VARCHAR)


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

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

SELECT price_range FROM HOTELS WHERE star_rating_code = "5"


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)

SELECT AVG(price_range) FROM HOTELS WHERE star_rating_code = "5" AND pets_allowed_yn = 1


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

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

SELECT Address FROM LOCATIONS WHERE Location_Name = "UK Gallery"


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

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

SELECT Other_Details FROM LOCATIONS WHERE Location_Name = "UK Gallery"


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

SELECT Location_Name FROM LOCATIONS WHERE Location_Name LIKE "%film%"


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

Context: CREATE TABLE PHOTOS (Name VARCHAR)


Question: What are the distinct visit dates?

Context: CREATE TABLE VISITS (Visit_Date VARCHAR)


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)

SELECT Name FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus"


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)

SELECT Name, Opening_Hours FROM TOURIST_ATTRACTIONS WHERE How_to_Get_There = "bus" OR How_to_Get_There = "walk"


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)

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


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)

SELECT T1.Museum_Details, T2.Opening_Hours FROM MUSEUMS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Museum_ID = T2.Tourist_Attraction_ID


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)

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"


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)

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"


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)

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


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)

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"


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)

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"


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)

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"


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)

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"


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)

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"


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)

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"


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

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

SELECT star_rating_code, AVG(price_range) FROM HOTELS GROUP BY star_rating_code


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

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

SELECT pets_allowed_yn, AVG(price_range) FROM HOTELS GROUP BY pets_allowed_yn


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)

SELECT hotel_id, star_rating_code FROM HOTELS ORDER BY price_range


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

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

SELECT other_hotel_details FROM HOTELS ORDER BY price_range DESC LIMIT 3


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)

SELECT other_hotel_details, star_rating_code FROM HOTELS ORDER BY price_range LIMIT 3


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

Context: CREATE TABLE Tourist_Attractions (How_to_Get_There VARCHAR)

SELECT How_to_Get_There FROM Tourist_Attractions GROUP BY How_to_Get_There ORDER BY COUNT(*) DESC LIMIT 1


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)

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


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

SELECT How_to_Get_There, COUNT(*) FROM Tourist_Attractions GROUP BY How_to_Get_There


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)

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


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

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


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

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


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)

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"


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)

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'


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

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"


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)

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"


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

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"


Question: How many tourists did not make any visit?

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

SELECT COUNT(*) FROM Visitors WHERE NOT Tourist_ID IN (SELECT Tourist_ID FROM Visits)


Question: How many video games exist?

Context: CREATE TABLE Video_games (Id VARCHAR)


Question: How many video game types exist?

Context: CREATE TABLE Video_games (gtype VARCHAR)

SELECT COUNT(DISTINCT gtype) FROM Video_games


Question: Show all video game types.


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

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

SELECT gname, gtype FROM Video_games ORDER BY gname


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

SELECT gname FROM Video_games WHERE gtype = "Collectible card game"


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

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

SELECT gtype FROM Video_games WHERE gname = "Call of Destiny"


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

SELECT COUNT(*) FROM Video_games WHERE gtype = "Massively multiplayer online game"


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

SELECT gtype, COUNT(*) FROM Video_games GROUP BY gtype


Question: Which game type has most number of games?

SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) DESC LIMIT 1


Question: Which game type has least number of games?

SELECT gtype FROM Video_games GROUP BY gtype ORDER BY COUNT(*) LIMIT 1


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

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

SELECT StuID FROM Student WHERE city_code = "CHI"


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

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

SELECT StuID FROM Student WHERE Advisor = 1121


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

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

SELECT Fname FROM Student WHERE Major = 600


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

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

SELECT major, AVG(age), MIN(age), MAX(age) FROM Student GROUP BY major


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

Context: CREATE TABLE Student (advisor VARCHAR)

SELECT advisor FROM Student GROUP BY advisor HAVING COUNT(*) >= 2


Question: How many sports do we have?

Context: CREATE TABLE Sportsinfo (sportname VARCHAR)

SELECT COUNT(DISTINCT sportname) FROM Sportsinfo


Question: How many students play sports?

Context: CREATE TABLE Sportsinfo (StuID VARCHAR)

SELECT COUNT(DISTINCT StuID) FROM Sportsinfo


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

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

SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'


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)

SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y'


Question: How many games are played for all students?

Context: CREATE TABLE Sportsinfo (gamesplayed INTEGER)


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

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

SELECT SUM(gamesplayed) FROM Sportsinfo WHERE sportname = "Football" AND onscholarship = 'Y'


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

SELECT sportname, COUNT(*) FROM Sportsinfo GROUP BY sportname


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

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

SELECT StuID, COUNT(*), SUM(gamesplayed) FROM Sportsinfo GROUP BY StuID


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)

SELECT StuID FROM Sportsinfo GROUP BY StuID HAVING SUM(hoursperweek) > 10


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)

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


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

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

SELECT sportname FROM Sportsinfo WHERE onscholarship = 'Y' GROUP BY sportname ORDER BY COUNT(*) DESC LIMIT 1


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

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

SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo


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)

SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'


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)

SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"


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

SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"


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)

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"


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)

SELECT SUM(hoursperweek), SUM(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20


Question: How many students play video games?

Context: CREATE TABLE Plays_games (StuID VARCHAR)

SELECT COUNT(DISTINCT StuID) FROM Plays_games


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

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

SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games


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

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

SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games


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

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

SELECT gameid, SUM(hours_played) FROM Plays_games GROUP BY gameid


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

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

SELECT Stuid, SUM(hours_played) FROM Plays_games GROUP BY Stuid


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)

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


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

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


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)

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"


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)

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"


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)

SELECT fname, age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")


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)

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")


Question: Find the name of all customers.

Context: CREATE TABLE customers (customer_name VARCHAR)


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

Context: CREATE TABLE order_items (order_quantity INTEGER)

SELECT AVG(order_quantity) FROM order_items


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

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

SELECT customer_name FROM customers WHERE payment_method = "Cash"


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)

SELECT date_became_customer FROM customers WHERE customer_id BETWEEN 10 AND 20


Question: Which payment method is used by most customers?

Context: CREATE TABLE customers (payment_method VARCHAR)

SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1


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

SELECT customer_name FROM customers WHERE payment_method = (SELECT payment_method FROM customers GROUP BY payment_method ORDER BY COUNT(*) DESC LIMIT 1)


Question: What are all the payment methods?

SELECT DISTINCT payment_method FROM customers


Question: What are the details of all products?

Context: CREATE TABLE products (product_details VARCHAR)

SELECT DISTINCT product_details FROM products


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

SELECT customer_name FROM customers WHERE customer_name LIKE "%Alex%"


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

SELECT product_details FROM products WHERE product_details LIKE "%Latte%" OR product_details LIKE "%Americano%"


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)

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"


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)

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"


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)

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"


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)

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)


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)

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


Question: Find the city with post code 255.

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

SELECT city FROM addresses WHERE zip_postcode = 255


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)

SELECT state_province_county, country FROM addresses WHERE zip_postcode LIKE "4%"


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

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

SELECT country FROM addresses GROUP BY country HAVING COUNT(address_id) > 4


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)

SELECT channel_code FROM customer_contact_channels GROUP BY channel_code HAVING COUNT(customer_id) < 5


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)

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"


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)

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"


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)

SELECT AVG(active_to_date - active_from_date) FROM customer_contact_channels


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)

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)


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)

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'


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)

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)


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)

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


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)

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


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)

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"


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)

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"


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

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

SELECT COUNT(DISTINCT customer_id) FROM customer_orders WHERE order_status = "Cancelled"


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

Context: CREATE TABLE customer_orders (order_details VARCHAR)

SELECT COUNT(*) FROM customer_orders WHERE order_details = "Second time"


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)

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"


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)

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"


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)

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"


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)

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


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)

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


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)

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


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)

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"


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

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

SELECT customer_name FROM customers WHERE payment_method <> 'Cash'


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)

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'


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)

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


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)

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'


Question: List the age of all music artists.

Context: CREATE TABLE artist (Age VARCHAR)


Question: What is the average age of all artists?

Context: CREATE TABLE artist (Age INTEGER)


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

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

SELECT Famous_Title FROM artist WHERE Artist = "Triumfall"


Question: What are the distinct Famous release dates?

Context: CREATE TABLE artist (Famous_Release_date VARCHAR)

SELECT DISTINCT (Famous_Release_date) FROM artist


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

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

SELECT Date_of_ceremony, RESULT FROM music_festival


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

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

SELECT Category FROM music_festival WHERE RESULT = "Awarded"


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

Context: CREATE TABLE volume (Weeks_on_Top INTEGER)

SELECT MAX(Weeks_on_Top), MIN(Weeks_on_Top) FROM volume


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

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

SELECT Song FROM volume WHERE Weeks_on_Top > 1


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

Context: CREATE TABLE volume (Song VARCHAR)


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

Context: CREATE TABLE volume (Artist_ID VARCHAR)

SELECT COUNT(DISTINCT Artist_ID) FROM volume


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)

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


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)

SELECT T2.Song FROM music_festival AS T1 JOIN volume AS T2 ON T1.Volume = T2.Volume_ID WHERE T1.Result = "Nominated"


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)

SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = "Gorgoroth"


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)

SELECT T2.Song FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age >= 32


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)

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


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)

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


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

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

SELECT Famous_Title, Age FROM artist ORDER BY Age DESC


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

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

SELECT Famous_Release_date FROM artist ORDER BY Age DESC LIMIT 1


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

Context: CREATE TABLE music_festival (Category VARCHAR)

SELECT Category, COUNT(*) FROM music_festival GROUP BY Category


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

Context: CREATE TABLE music_festival (RESULT VARCHAR)

SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1


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

SELECT Category FROM music_festival GROUP BY Category HAVING COUNT(*) > 1


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

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

SELECT Song FROM volume ORDER BY Weeks_on_Top DESC LIMIT 1


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)

SELECT Famous_Title FROM artist WHERE NOT Artist_ID IN (SELECT Artist_ID FROM volume)


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.

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


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)

SELECT Date_of_ceremony FROM music_festival WHERE Category = "Best Song" AND RESULT = "Awarded"


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)

SELECT Issue_Date FROM volume ORDER BY Weeks_on_Top LIMIT 1


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

SELECT RESULT, COUNT(*) FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC


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)

SELECT Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 23


Question: How many roller coasters are there?

Context: CREATE TABLE roller_coaster (Id VARCHAR)


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

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

SELECT Name FROM roller_coaster ORDER BY LENGTH


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

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

SELECT LENGTH, Height FROM roller_coaster


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

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

SELECT Name FROM country WHERE Languages <> "German"


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)

SELECT Status FROM roller_coaster WHERE LENGTH > 3300 OR Height > 100


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

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

SELECT Speed FROM roller_coaster ORDER BY LENGTH DESC LIMIT 1


Question: What is the average speed of roller coasters?

Context: CREATE TABLE roller_coaster (Speed INTEGER)


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

Context: CREATE TABLE roller_coaster (Status VARCHAR)

SELECT Status, COUNT(*) FROM roller_coaster GROUP BY Status


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

SELECT Status FROM roller_coaster GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1


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

SELECT Status FROM roller_coaster GROUP BY Status HAVING COUNT(*) > 2


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

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

SELECT Park FROM roller_coaster ORDER BY Speed DESC LIMIT 1


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)

SELECT T2.Name, T1.Name FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID


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)

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