Question: Which district has the least area?

Context: CREATE TABLE district (district_name VARCHAR, city_area VARCHAR)

SELECT district_name FROM district ORDER BY city_area LIMIT 1


Question: Find the total population of the top 3 districts with the largest area.

Context: CREATE TABLE district (city_population INTEGER, city_area VARCHAR)

SELECT SUM(city_population) FROM district ORDER BY city_area DESC LIMIT 3


Question: Find all types of store and number of them.

Context: CREATE TABLE store (TYPE VARCHAR)

SELECT TYPE, COUNT(*) FROM store GROUP BY TYPE


Question: Find the names of all stores in Khanewal District.

Context: CREATE TABLE district (district_id VARCHAR, district_name VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR); CREATE TABLE store (store_name VARCHAR, store_id VARCHAR)

SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District"


Question: Find all the stores in the district with the most population.

Context: CREATE TABLE store_district (store_id VARCHAR); CREATE TABLE district (district_id VARCHAR, city_population VARCHAR); CREATE TABLE store (store_name VARCHAR, store_id VARCHAR)

SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id WHERE district_id = (SELECT district_id FROM district ORDER BY city_population DESC LIMIT 1)


Question: Which city is the headquarter of the store named "Blackville" in?

Context: CREATE TABLE store (store_id VARCHAR, store_name VARCHAR); CREATE TABLE district (headquartered_city VARCHAR, district_id VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR)

SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.store_name = "Blackville"


Question: Find the number of stores in each city.

Context: CREATE TABLE district (headquartered_city VARCHAR, district_id VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR); CREATE TABLE store (store_id VARCHAR)

SELECT t3.headquartered_city, COUNT(*) FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city


Question: Find the city with the most number of stores.

SELECT t3.headquartered_city FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id GROUP BY t3.headquartered_city ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the average pages per minute color?

Context: CREATE TABLE product (pages_per_minute_color INTEGER)

SELECT AVG(pages_per_minute_color) FROM product


Question: What products are available at store named "Miramichi"?

Context: CREATE TABLE store_product (product_id VARCHAR, store_id VARCHAR); CREATE TABLE store (store_id VARCHAR, store_name VARCHAR); CREATE TABLE product (product VARCHAR, product_id VARCHAR)

SELECT t1.product FROM product AS t1 JOIN store_product AS t2 ON t1.product_id = t2.product_id JOIN store AS t3 ON t2.store_id = t3.store_id WHERE t3.store_name = "Miramichi"


Question: Find products with max page size as "A4" and pages per minute color smaller than 5.

Context: CREATE TABLE product (product VARCHAR, max_page_size VARCHAR, pages_per_minute_color VARCHAR)

SELECT product FROM product WHERE max_page_size = "A4" AND pages_per_minute_color < 5


Question: Find products with max page size as "A4" or pages per minute color smaller than 5.

SELECT product FROM product WHERE max_page_size = "A4" OR pages_per_minute_color < 5


Question: Find all the product whose name contains the word "Scanner".

Context: CREATE TABLE product (product VARCHAR)

SELECT product FROM product WHERE product LIKE "%Scanner%"


Question: Find the most prominent max page size among all the products.

Context: CREATE TABLE product (max_page_size VARCHAR)

SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the products that are not using the most frequently-used max page size.

Context: CREATE TABLE product (product VARCHAR, max_page_size VARCHAR)

SELECT product FROM product WHERE product <> (SELECT max_page_size FROM product GROUP BY max_page_size ORDER BY COUNT(*) DESC LIMIT 1)


Question: Find the total population of the districts where the area is bigger than the average city area.

Context: CREATE TABLE district (city_population INTEGER, city_area INTEGER)

SELECT SUM(city_population) FROM district WHERE city_area > (SELECT AVG(city_area) FROM district)


Question: Find the names of districts where have both city mall and village store type stores.

Context: CREATE TABLE district (District_name VARCHAR, district_id VARCHAR); CREATE TABLE store (store_id VARCHAR, Type VARCHAR); CREATE TABLE store_district (store_id VARCHAR, district_id VARCHAR)

SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "City Mall" INTERSECT SELECT t3.District_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t1.Type = "Village Store"


Question: What is the total enrollment number of all colleges?

Context: CREATE TABLE College (enr INTEGER)


Question: What is the average enrollment number?

Context: CREATE TABLE College (enr INTEGER)


Question: How many colleges in total?

Context: CREATE TABLE College (Id VARCHAR)


Question: How many players have more than 1000 hours of training?

Context: CREATE TABLE Player (HS INTEGER)

SELECT COUNT(*) FROM Player WHERE HS > 1000


Question: How many colleges has more than 15000 students?

Context: CREATE TABLE College (enr INTEGER)

SELECT COUNT(*) FROM College WHERE enr > 15000


Question: What is the average training hours of all players?

Context: CREATE TABLE Player (HS INTEGER)


Question: Find the name and training hours of players whose hours are below 1500.

Context: CREATE TABLE Player (pName VARCHAR, HS INTEGER)

SELECT pName, HS FROM Player WHERE HS < 1500


Question: How many different colleges do attend the tryout test?

Context: CREATE TABLE tryout (cName VARCHAR)

SELECT COUNT(DISTINCT cName) FROM tryout


Question: What are the unique types of player positions in the tryout?

Context: CREATE TABLE tryout (pPos VARCHAR)


Question: How many students got accepted after the tryout?

Context: CREATE TABLE tryout (decision VARCHAR)

SELECT COUNT(*) FROM tryout WHERE decision = 'yes'


Question: How many students whose are playing the role of goalie?

Context: CREATE TABLE tryout (pPos VARCHAR)

SELECT COUNT(*) FROM tryout WHERE pPos = 'goalie'


Question: Find the max, average and min training hours of all players.

Context: CREATE TABLE Player (HS INTEGER)

SELECT AVG(HS), MAX(HS), MIN(HS) FROM Player


Question: What is average enrollment of colleges in the state FL?

Context: CREATE TABLE College (enr INTEGER, state VARCHAR)

SELECT AVG(enr) FROM College WHERE state = 'FL'


Question: What are the names of players whose training hours is between 500 and 1500?

SELECT pName FROM Player WHERE HS BETWEEN 500 AND 1500


Question: Find the players whose names contain letter 'a'.

Context: CREATE TABLE Player (pName VARCHAR)

SELECT DISTINCT pName FROM Player WHERE pName LIKE '%a%'


Question: Find the name, enrollment of the colleges whose size is bigger than 10000 and location is in state LA.

Context: CREATE TABLE College (cName VARCHAR, enr VARCHAR, state VARCHAR)

SELECT cName, enr FROM College WHERE enr > 10000 AND state = "LA"


Question: List all information about college sorted by enrollment number in the ascending order.

Context: CREATE TABLE College (enr VARCHAR)


Question: List the name of the colleges whose enrollment is greater 18000 sorted by the college's name.

Context: CREATE TABLE College (cName VARCHAR, enr INTEGER)

SELECT cName FROM College WHERE enr > 18000 ORDER BY cName


Question: Find the name of players whose card is yes in the descending order of training hours.

Context: CREATE TABLE Player (pName VARCHAR, yCard VARCHAR, HS VARCHAR)

SELECT pName FROM Player WHERE yCard = 'yes' ORDER BY HS DESC


Question: Find the name of different colleges involved in the tryout in alphabetical order.

Context: CREATE TABLE tryout (cName VARCHAR)

SELECT DISTINCT cName FROM tryout ORDER BY cName


Question: Which position is most popular among players in the tryout?

Context: CREATE TABLE tryout (pPos VARCHAR)

SELECT pPos FROM tryout GROUP BY pPos ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the number of students who participate in the tryout for each college ordered by descending count.

Context: CREATE TABLE tryout (cName VARCHAR)

SELECT COUNT(*), cName FROM tryout GROUP BY cName ORDER BY COUNT(*) DESC


Question: What is minimum hours of the students playing in different position?

Context: CREATE TABLE player (HS INTEGER, pID VARCHAR); CREATE TABLE tryout (pPos VARCHAR, pID VARCHAR)

SELECT MIN(T2.HS), T1.pPos FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID GROUP BY T1.pPos


Question: What are the names of schools with the top 3 largest size?

Context: CREATE TABLE college (cName VARCHAR, enr VARCHAR)

SELECT cName FROM college ORDER BY enr DESC LIMIT 3


Question: What is the name of school that has the smallest enrollment in each state?

Context: CREATE TABLE college (cName VARCHAR, state VARCHAR, enr INTEGER)

SELECT cName, state, MIN(enr) FROM college GROUP BY state


Question: Find the states where have some college students in tryout.

Context: CREATE TABLE college (cName VARCHAR); CREATE TABLE tryout (cName VARCHAR)

SELECT DISTINCT state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName


Question: Find the states where have some college students in tryout and their decisions are yes.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

SELECT DISTINCT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes'


Question: Find the name and college of students whose decisions are yes in the tryout.

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR, decision VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

SELECT T1.pName, T2.cName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes'


Question: Find the name of all students who were in the tryout sorted in alphabetic order.

Context: CREATE TABLE tryout (pID VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID ORDER BY T1.pName


Question: Find the name and hours of the students whose tryout decision is yes.

Context: CREATE TABLE player (pName VARCHAR, HS VARCHAR, pID VARCHAR); CREATE TABLE tryout (pID VARCHAR, decision VARCHAR)

SELECT T1.pName, T1.HS FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes'


Question: Find the states of the colleges that have students in the tryout who played in striker position.

Context: CREATE TABLE tryout (cName VARCHAR, pPos VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'striker'


Question: Find the names of the students who are in the position of striker and got a yes tryout decision.

Context: CREATE TABLE tryout (pID VARCHAR, decision VARCHAR, pPos VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

SELECT T1.pName FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes' AND T2.pPos = 'striker'


Question: Find the state of the college which player Charles is attending.

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR); CREATE TABLE player (pID VARCHAR, pName VARCHAR); CREATE TABLE college (state VARCHAR, cName VARCHAR)

SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName JOIN player AS T3 ON T2.pID = T3.pID WHERE T3.pName = 'Charles'


Question: Find the average and maximum hours for the students whose tryout decision is yes.

Context: CREATE TABLE player (HS INTEGER, pID VARCHAR); CREATE TABLE tryout (pID VARCHAR, decision VARCHAR)

SELECT AVG(T1.HS), MAX(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'yes'


Question: Find the average hours for the students whose tryout decision is no.

SELECT AVG(T1.HS) FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T2.decision = 'no'


Question: What is the maximum training hours for the students whose training hours is greater than 1000 in different positions?

SELECT MAX(T1.HS), pPos FROM player AS T1 JOIN tryout AS T2 ON T1.pID = T2.pID WHERE T1.HS > 1000 GROUP BY T2.pPos


Question: Which colleges do the tryout players whose name starts with letter D go to?

Context: CREATE TABLE tryout (cName VARCHAR, pID VARCHAR); CREATE TABLE player (pID VARCHAR, pName VARCHAR)

SELECT T1.cName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T2.pName LIKE 'D%'


Question: Which college has any student who is a goalie and succeeded in the tryout.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR, pPos VARCHAR)

SELECT cName FROM tryout WHERE decision = 'yes' AND pPos = 'goalie'


Question: Find the name of the tryout players who are from the college with largest size.

Context: CREATE TABLE college (cName VARCHAR, enr VARCHAR); CREATE TABLE tryout (pID VARCHAR, cName VARCHAR); CREATE TABLE player (pName VARCHAR, pID VARCHAR)

SELECT T2.pName FROM tryout AS T1 JOIN player AS T2 ON T1.pID = T2.pID WHERE T1.cName = (SELECT cName FROM college ORDER BY enr DESC LIMIT 1)


Question: What is the state and enrollment of the colleges where have any students who got accepted in the tryout decision.

Context: CREATE TABLE tryout (cName VARCHAR, decision VARCHAR); CREATE TABLE college (state VARCHAR, enr VARCHAR, cName VARCHAR)

SELECT DISTINCT T1.state, T1.enr FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes'


Question: Find the names of either colleges in LA with greater than 15000 size or in state AZ with less than 13000 enrollment.

Context: CREATE TABLE College (cName VARCHAR, enr VARCHAR, state VARCHAR)

SELECT cName FROM College WHERE enr < 13000 AND state = "AZ" UNION SELECT cName FROM College WHERE enr > 15000 AND state = "LA"


Question: Find the names of schools that have some students playing in goalie and mid positions.

Context: CREATE TABLE tryout (cName VARCHAR, pPos VARCHAR)

SELECT cName FROM tryout WHERE pPos = 'goalie' INTERSECT SELECT cName FROM tryout WHERE pPos = 'mid'


Question: Find the names of states that have some college students playing in goalie and mid positions.

SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie' INTERSECT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid'


Question: How many schools have some students playing in goalie and mid positions.

SELECT COUNT(*) FROM (SELECT cName FROM tryout WHERE pPos = 'goalie' INTERSECT SELECT cName FROM tryout WHERE pPos = 'mid')


Question: Find the names of schools that have some players in the mid position but not in the goalie position.

SELECT cName FROM tryout WHERE pPos = 'mid' EXCEPT SELECT cName FROM tryout WHERE pPos = 'goalie'


Question: Find the names of states that have some college students playing in the mid position but not in the goalie position.

SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie'


Question: How many states that have some college students playing in the mid position but not in the goalie position.

SELECT COUNT(*) FROM (SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie')


Question: Find the states where have the colleges whose enrollments are less than the largest size.

Context: CREATE TABLE college (state VARCHAR, enr INTEGER)

SELECT DISTINCT state FROM college WHERE enr < (SELECT MAX(enr) FROM college)


Question: Find names of colleges with enrollment greater than that of some (at least one) college in the FL state.

Context: CREATE TABLE college (cName VARCHAR, enr INTEGER, state VARCHAR)

SELECT DISTINCT cName FROM college WHERE enr > (SELECT MIN(enr) FROM college WHERE state = 'FL')


Question: Find names of all colleges whose enrollment is greater than that of all colleges in the FL state.

SELECT cName FROM college WHERE enr > (SELECT MAX(enr) FROM college WHERE state = 'FL')


Question: What is the total number of enrollment of schools that do not have any goalie player?

Context: CREATE TABLE college (enr INTEGER, cName VARCHAR, pPos VARCHAR); CREATE TABLE tryout (enr INTEGER, cName VARCHAR, pPos VARCHAR)

SELECT SUM(enr) FROM college WHERE NOT cName IN (SELECT cName FROM tryout WHERE pPos = "goalie")


Question: What is the number of states that has some college whose enrollment is larger than the average enrollment?

SELECT COUNT(DISTINCT state) FROM college WHERE enr > (SELECT AVG(enr) FROM college)


Question: What is the number of states that has some colleges whose enrollment is smaller than the average enrollment?

SELECT COUNT(DISTINCT state) FROM college WHERE enr < (SELECT AVG(enr) FROM college)


Question: How many devices are there?

Context: CREATE TABLE device (Id VARCHAR)


Question: List the carriers of devices in ascending alphabetical order.

Context: CREATE TABLE device (Carrier VARCHAR)

SELECT Carrier FROM device ORDER BY Carrier


Question: What are the carriers of devices whose software platforms are not "Android"?

Context: CREATE TABLE device (Carrier VARCHAR, Software_Platform VARCHAR)

SELECT Carrier FROM device WHERE Software_Platform <> 'Android'


Question: What are the names of shops in ascending order of open year?

Context: CREATE TABLE shop (Shop_Name VARCHAR, Open_Year VARCHAR)

SELECT Shop_Name FROM shop ORDER BY Open_Year


Question: What is the average quantity of stocks?

Context: CREATE TABLE stock (Quantity INTEGER)


Question: What are the names and location of the shops in ascending alphabetical order of name.

Context: CREATE TABLE shop (Shop_Name VARCHAR, LOCATION VARCHAR)

SELECT Shop_Name, LOCATION FROM shop ORDER BY Shop_Name


Question: How many different software platforms are there for devices?

Context: CREATE TABLE device (Software_Platform VARCHAR)

SELECT COUNT(DISTINCT Software_Platform) FROM device


Question: List the open date of open year of the shop named "Apple".

Context: CREATE TABLE shop (Open_Date VARCHAR, Open_Year VARCHAR, Shop_Name VARCHAR)

SELECT Open_Date, Open_Year FROM shop WHERE Shop_Name = "Apple"


Question: List the name of the shop with the latest open year.

SELECT Shop_Name FROM shop ORDER BY Open_Year DESC LIMIT 1


Question: Show names of shops and the carriers of devices they have in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Device_ID VARCHAR, Shop_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

SELECT T3.Shop_Name, T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID = T2.Device_ID JOIN shop AS T3 ON T1.Shop_ID = T3.Shop_ID


Question: Show names of shops that have more than one kind of device in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Shop_ID VARCHAR)

SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID HAVING COUNT(*) > 1


Question: Show the name of the shop that has the most kind of devices in stock.

SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the name of the shop that have the largest quantity of devices in stock.

Context: CREATE TABLE stock (Shop_ID VARCHAR, quantity INTEGER); CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR)

SELECT T2.Shop_Name FROM stock AS T1 JOIN shop AS T2 ON T1.Shop_ID = T2.Shop_ID GROUP BY T1.Shop_ID ORDER BY SUM(T1.quantity) DESC LIMIT 1


Question: Please show different software platforms and the corresponding number of devices using each.

SELECT Software_Platform, COUNT(*) FROM device GROUP BY Software_Platform


Question: Please show the software platforms of devices in descending order of the count.

SELECT Software_Platform FROM device GROUP BY Software_Platform ORDER BY COUNT(*) DESC


Question: List the software platform shared by the greatest number of devices.

SELECT Software_Platform FROM device GROUP BY Software_Platform ORDER BY COUNT(*) DESC LIMIT 1


Question: List the names of shops that have no devices in stock.

Context: CREATE TABLE shop (Shop_Name VARCHAR, Shop_ID VARCHAR); CREATE TABLE stock (Shop_Name VARCHAR, Shop_ID VARCHAR)

SELECT Shop_Name FROM shop WHERE NOT Shop_ID IN (SELECT Shop_ID FROM stock)


Question: Show the locations shared by shops with open year later than 2012 and shops with open year before 2008.

Context: CREATE TABLE shop (LOCATION VARCHAR, Open_Year INTEGER)

SELECT LOCATION FROM shop WHERE Open_Year > 2012 INTERSECT SELECT LOCATION FROM shop WHERE Open_Year < 2008


Question: List the carriers of devices that have no devices in stock.

Context: CREATE TABLE stock (Carrier VARCHAR, Device_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

SELECT Carrier FROM device WHERE NOT Device_ID IN (SELECT Device_ID FROM stock)


Question: Show the carriers of devices in stock at more than one shop.

Context: CREATE TABLE stock (Device_ID VARCHAR); CREATE TABLE device (Carrier VARCHAR, Device_ID VARCHAR)

SELECT T2.Carrier FROM stock AS T1 JOIN device AS T2 ON T1.Device_ID = T2.Device_ID GROUP BY T1.Device_ID HAVING COUNT(*) > 1


Question: How many bookings do we have?

Context: CREATE TABLE BOOKINGS (Id VARCHAR)


Question: List the order dates of all the bookings.

Context: CREATE TABLE BOOKINGS (Order_Date VARCHAR)


Question: Show all the planned delivery dates and actual delivery dates of bookings.

Context: CREATE TABLE BOOKINGS (Planned_Delivery_Date VARCHAR, Actual_Delivery_Date VARCHAR)

SELECT Planned_Delivery_Date, Actual_Delivery_Date FROM BOOKINGS


Question: How many customers do we have?

Context: CREATE TABLE CUSTOMERS (Id VARCHAR)


Question: What are the phone and email for customer Harold?

Context: CREATE TABLE CUSTOMERS (Customer_Phone VARCHAR, Customer_Email_Address VARCHAR, Customer_Name VARCHAR)

SELECT Customer_Phone, Customer_Email_Address FROM CUSTOMERS WHERE Customer_Name = "Harold"


Question: Show all the Store_Name of drama workshop groups.

Context: CREATE TABLE Drama_Workshop_Groups (Store_Name VARCHAR)

SELECT Store_Name FROM Drama_Workshop_Groups


Question: Show the minimum, average, maximum order quantity of all invoices.

Context: CREATE TABLE INVOICES (Order_Quantity INTEGER)

SELECT MIN(Order_Quantity), AVG(Order_Quantity), MAX(Order_Quantity) FROM INVOICES


Question: What are the distinct payment method codes in all the invoices?

Context: CREATE TABLE INVOICES (payment_method_code VARCHAR)

SELECT DISTINCT payment_method_code FROM INVOICES


Question: What is the description of the marketing region China?

Context: CREATE TABLE Marketing_Regions (Marketing_Region_Descriptrion VARCHAR, Marketing_Region_Name VARCHAR)

SELECT Marketing_Region_Descriptrion FROM Marketing_Regions WHERE Marketing_Region_Name = "China"


Question: Show all the distinct product names with price higher than the average.

Context: CREATE TABLE PRODUCTS (Product_Name VARCHAR, Product_Price INTEGER)

SELECT DISTINCT Product_Name FROM PRODUCTS WHERE Product_Price > (SELECT AVG(Product_Price) FROM PRODUCTS)


Question: What is the name of the most expensive product?

Context: CREATE TABLE PRODUCTS (Product_Name VARCHAR, Product_Price VARCHAR)

SELECT Product_Name FROM PRODUCTS ORDER BY Product_Price DESC LIMIT 1


Question: What is the phone number of the performer Ashley?

Context: CREATE TABLE PERFORMERS (Customer_Phone VARCHAR, Customer_Name VARCHAR)

SELECT Customer_Phone FROM PERFORMERS WHERE Customer_Name = "Ashley"


Question: Show all payment method codes and the number of orders for each code.

SELECT payment_method_code, COUNT(*) FROM INVOICES GROUP BY payment_method_code


Question: What is the payment method code used by the most orders?

SELECT payment_method_code FROM INVOICES GROUP BY payment_method_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Which city is the address of the store named "FJA Filming" located in?

Context: CREATE TABLE Addresses (City_Town VARCHAR, Address_ID VARCHAR); CREATE TABLE Stores (Address_ID VARCHAR, Store_Name VARCHAR)

SELECT T1.City_Town FROM Addresses AS T1 JOIN Stores AS T2 ON T1.Address_ID = T2.Address_ID WHERE T2.Store_Name = "FJA Filming"


Question: What are the states or counties of the address of the stores with marketing region code "CA"?

Context: CREATE TABLE Addresses (State_County VARCHAR, Address_ID VARCHAR); CREATE TABLE Stores (Address_ID VARCHAR, Marketing_Region_Code VARCHAR)

SELECT T1.State_County FROM Addresses AS T1 JOIN Stores AS T2 ON T1.Address_ID = T2.Address_ID WHERE T2.Marketing_Region_Code = "CA"


Question: What is the name of the marketing region that the store Rob Dinning belongs to?

Context: CREATE TABLE Marketing_Regions (Marketing_Region_Name VARCHAR, Marketing_Region_Code VARCHAR); CREATE TABLE Stores (Marketing_Region_Code VARCHAR, Store_Name VARCHAR)

SELECT T1.Marketing_Region_Name FROM Marketing_Regions AS T1 JOIN Stores AS T2 ON T1.Marketing_Region_Code = T2.Marketing_Region_Code WHERE T2.Store_Name = "Rob Dinning"


Question: What are the descriptions of the service types with product price above 100?

Context: CREATE TABLE Services (Service_Type_Code VARCHAR, Product_Price INTEGER); CREATE TABLE Ref_Service_Types (Service_Type_Description VARCHAR, Service_Type_Code VARCHAR)

SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Price > 100


Question: What is the description, code and the corresponding count of each service type?

Context: CREATE TABLE Services (Service_Type_Code VARCHAR); CREATE TABLE Ref_Service_Types (Service_Type_Description VARCHAR, Service_Type_Code VARCHAR)

SELECT T1.Service_Type_Description, T2.Service_Type_Code, COUNT(*) FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T2.Service_Type_Code


Question: What is the description and code of the type of service that is performed the most often?

SELECT T1.Service_Type_Description, T1.Service_Type_Code FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T1.Service_Type_Code ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the phones and emails of workshop groups in which services are performed?

Context: CREATE TABLE Services (Workshop_Group_ID VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Phone VARCHAR, Store_Email_Address VARCHAR, Workshop_Group_ID VARCHAR)

SELECT T1.Store_Phone, T1.Store_Email_Address FROM Drama_Workshop_Groups AS T1 JOIN Services AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID


Question: What are the names of workshop groups in which services with product name "film" are performed?

Context: CREATE TABLE Services (Workshop_Group_ID VARCHAR, Product_Name VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Phone VARCHAR, Store_Email_Address VARCHAR, Workshop_Group_ID VARCHAR)

SELECT T1.Store_Phone, T1.Store_Email_Address FROM Drama_Workshop_Groups AS T1 JOIN Services AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID WHERE T2.Product_Name = "film"


Question: What are the different product names? What is the average product price for each of them?

SELECT Product_Name, AVG(Product_Price) FROM PRODUCTS GROUP BY Product_Name


Question: What are the product names with average product price smaller than 1000000?

SELECT Product_Name FROM PRODUCTS GROUP BY Product_Name HAVING AVG(Product_Price) < 1000000


Question: What are the total order quantities of photo products?

Context: CREATE TABLE ORDER_ITEMS (Order_Quantity INTEGER, Product_ID VARCHAR); CREATE TABLE Products (Product_ID VARCHAR, Product_Name VARCHAR)

SELECT SUM(T1.Order_Quantity) FROM ORDER_ITEMS AS T1 JOIN Products AS T2 ON T1.Product_ID = T2.Product_ID WHERE T2.Product_Name = "photo"


Question: What are the order details of the products with price higher than 2000?

Context: CREATE TABLE Products (Product_ID VARCHAR, Product_price INTEGER); CREATE TABLE ORDER_ITEMS (Other_Item_Details VARCHAR, Product_ID VARCHAR)

SELECT T1.Other_Item_Details FROM ORDER_ITEMS AS T1 JOIN Products AS T2 ON T1.Product_ID = T2.Product_ID WHERE T2.Product_price > 2000


Question: What are the actual delivery dates of orders with quantity 1?

Context: CREATE TABLE Customer_Orders (Actual_Delivery_Date VARCHAR, Order_ID VARCHAR); CREATE TABLE ORDER_ITEMS (Order_ID VARCHAR, Order_Quantity VARCHAR)

SELECT T1.Actual_Delivery_Date FROM Customer_Orders AS T1 JOIN ORDER_ITEMS AS T2 ON T1.Order_ID = T2.Order_ID WHERE T2.Order_Quantity = 1


Question: What are the order dates of orders with price higher than 1000?

Context: CREATE TABLE Products (Product_ID VARCHAR, Product_price INTEGER); CREATE TABLE ORDER_ITEMS (Order_ID VARCHAR, Product_ID VARCHAR); CREATE TABLE Customer_Orders (Order_Date VARCHAR, Order_ID VARCHAR)

SELECT T1.Order_Date FROM Customer_Orders AS T1 JOIN ORDER_ITEMS AS T2 ON T1.Order_ID = T2.Order_ID JOIN Products AS T3 ON T2.Product_ID = T3.Product_ID WHERE T3.Product_price > 1000


Question: How many distinct currency codes are there for all drama workshop groups?

Context: CREATE TABLE Drama_Workshop_Groups (Currency_Code VARCHAR)

SELECT COUNT(DISTINCT Currency_Code) FROM Drama_Workshop_Groups


Question: What are the names of the drama workshop groups with address in Feliciaberg city?

Context: CREATE TABLE Addresses (Address_ID VARCHAR, City_Town VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Name VARCHAR, Address_ID VARCHAR)

SELECT T2.Store_Name FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID WHERE T1.City_Town = "Feliciaberg"


Question: What are the email addresses of the drama workshop groups with address in Alaska state?

Context: CREATE TABLE Drama_Workshop_Groups (Store_Email_Address VARCHAR, Address_ID VARCHAR); CREATE TABLE Addresses (Address_ID VARCHAR, State_County VARCHAR)

SELECT T2.Store_Email_Address FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID WHERE T1.State_County = "Alaska"


Question: Show all cities along with the number of drama workshop groups in each city.

Context: CREATE TABLE Addresses (City_Town VARCHAR, Address_ID VARCHAR); CREATE TABLE Drama_Workshop_Groups (Address_ID VARCHAR)

SELECT T1.City_Town, COUNT(*) FROM Addresses AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Address_ID = T2.Address_ID GROUP BY T1.City_Town


Question: What is the marketing region code that has the most drama workshop groups?

Context: CREATE TABLE Drama_Workshop_Groups (Marketing_Region_Code VARCHAR)

SELECT Marketing_Region_Code FROM Drama_Workshop_Groups GROUP BY Marketing_Region_Code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all cities where at least one customer lives in but no performer lives in.

Context: CREATE TABLE Customers (Address_ID VARCHAR); CREATE TABLE Addresses (City_Town VARCHAR, Address_ID VARCHAR); CREATE TABLE Performers (Address_ID VARCHAR)

SELECT T1.City_Town FROM Addresses AS T1 JOIN Customers AS T2 ON T1.Address_ID = T2.Address_ID EXCEPT SELECT T1.City_Town FROM Addresses AS T1 JOIN Performers AS T2 ON T1.Address_ID = T2.Address_ID


Question: What is the most frequent status of bookings?

Context: CREATE TABLE BOOKINGS (Status_Code VARCHAR)

SELECT Status_Code FROM BOOKINGS GROUP BY Status_Code ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names of the workshop groups that have bookings with status code "stop"?

Context: CREATE TABLE Bookings (Workshop_Group_ID VARCHAR, Status_Code VARCHAR); CREATE TABLE Drama_Workshop_Groups (Store_Name VARCHAR, Workshop_Group_ID VARCHAR)

SELECT T2.Store_Name FROM Bookings AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID WHERE T1.Status_Code = "stop"


Question: Show the names of all the clients with no booking.

Context: CREATE TABLE Clients (Customer_Name VARCHAR, Client_ID VARCHAR); CREATE TABLE Bookings (Customer_ID VARCHAR); CREATE TABLE Clients (Customer_Name VARCHAR)

SELECT Customer_Name FROM Clients EXCEPT SELECT T2.Customer_Name FROM Bookings AS T1 JOIN Clients AS T2 ON T1.Customer_ID = T2.Client_ID


Question: What is the average quantities ordered with payment method code "MasterCard" on invoices?

Context: CREATE TABLE Invoices (Order_Quantity INTEGER, payment_method_code VARCHAR)

SELECT AVG(Order_Quantity) FROM Invoices WHERE payment_method_code = "MasterCard"


Question: What is the product ID of the most frequently ordered item on invoices?

Context: CREATE TABLE INVOICES (Product_ID VARCHAR)

SELECT Product_ID FROM INVOICES GROUP BY Product_ID ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the description of the service type which offers both the photo product and the film product?

Context: CREATE TABLE Ref_Service_Types (Service_Type_Description VARCHAR, Service_Type_Code VARCHAR); CREATE TABLE Services (Service_Type_Code VARCHAR, Product_Name VARCHAR)

SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Name = 'photo' INTERSECT SELECT T1.Service_Type_Description FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Name = 'film'


Question: How many bands are there?

Context: CREATE TABLE Band (Id VARCHAR)


Question: What are all the labels?

Context: CREATE TABLE Albums (label VARCHAR)


Question: Find all the albums in 2012.

Context: CREATE TABLE Albums (YEAR VARCHAR)


Question: Find all the stage positions of the musicians with first name "Solveig"

Context: CREATE TABLE Band (id VARCHAR); CREATE TABLE Performance (stageposition VARCHAR, bandmate VARCHAR)

SELECT DISTINCT T1.stageposition FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id WHERE Firstname = "Solveig"


Question: How many songs are there?

Context: CREATE TABLE Songs (Id VARCHAR)


Question: Find all the songs performed by artist with last name "Heilo"

Context: CREATE TABLE Songs (Title VARCHAR, SongId VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR); CREATE TABLE Band (id VARCHAR, Lastname VARCHAR)

SELECT T3.Title FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T2.Lastname = "Heilo"


Question: Hom many musicians performed in the song "Flash"?

Context: CREATE TABLE performance (bandmate VARCHAR, songid VARCHAR); CREATE TABLE songs (songid VARCHAR, Title VARCHAR); CREATE TABLE band (id VARCHAR)

SELECT COUNT(*) FROM performance AS T1 JOIN band AS T2 ON T1.bandmate = T2.id JOIN songs AS T3 ON T3.songid = T1.songid WHERE T3.Title = "Flash"


Question: Find all the songs produced by artists with first name "Marianne".

Context: CREATE TABLE Songs (Title VARCHAR, SongId VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR); CREATE TABLE Band (id VARCHAR, firstname VARCHAR)

SELECT T3.Title FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T2.firstname = "Marianne"


Question: Who performed the song named "Badlands"? Show the first name and the last name.

Context: CREATE TABLE Band (firstname VARCHAR, lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR); CREATE TABLE Songs (SongId VARCHAR, Title VARCHAR)

SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Badlands"


Question: Who is performing in the back stage position for the song "Badlands"? Show the first name and the last name.

Context: CREATE TABLE Band (firstname VARCHAR, lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR, StagePosition VARCHAR); CREATE TABLE Songs (SongId VARCHAR, Title VARCHAR)

SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Badlands" AND T1.StagePosition = "back"


Question: How many unique labels are there for albums?

Context: CREATE TABLE albums (label VARCHAR)

SELECT COUNT(DISTINCT label) FROM albums


Question: What is the label that has the most albums?

Context: CREATE TABLE albums (label VARCHAR)

SELECT label FROM albums GROUP BY label ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the last name of the musician that have produced the most number of songs?

Context: CREATE TABLE Songs (SongId VARCHAR); CREATE TABLE Band (lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR)

SELECT T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId GROUP BY lastname ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the last name of the musician that has been at the back position the most?

Context: CREATE TABLE Band (lastname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR)

SELECT T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id WHERE stageposition = "back" GROUP BY lastname ORDER BY COUNT(*) DESC LIMIT 1


Question: Find all the songs whose name contains the word "the".

Context: CREATE TABLE songs (title VARCHAR)

SELECT title FROM songs WHERE title LIKE '% the %'


Question: What are all the instruments used?

Context: CREATE TABLE Instruments (instrument VARCHAR)

SELECT DISTINCT instrument FROM Instruments


Question: What instrument did the musician with last name "Heilo" use in the song "Le Pop"?

Context: CREATE TABLE Songs (SongId VARCHAR, songid VARCHAR, title VARCHAR); CREATE TABLE Performance (bandmate VARCHAR, SongId VARCHAR); CREATE TABLE Band (id VARCHAR, lastname VARCHAR); CREATE TABLE Instruments (instrument VARCHAR, songid VARCHAR, bandmateid VARCHAR)

SELECT T4.instrument FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId JOIN Instruments AS T4 ON T4.songid = T3.songid AND T4.bandmateid = T2.id WHERE T2.lastname = "Heilo" AND T3.title = "Le Pop"


Question: What is the most used instrument?

Context: CREATE TABLE instruments (instrument VARCHAR)

SELECT instrument FROM instruments GROUP BY instrument ORDER BY COUNT(*) DESC LIMIT 1


Question: How many songs have used the instrument "drums"?

SELECT COUNT(*) FROM instruments WHERE instrument = "drums"


Question: What instruments does the the song "Le Pop" use?

Context: CREATE TABLE instruments (songid VARCHAR); CREATE TABLE songs (songid VARCHAR)

SELECT instrument FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Le Pop"


Question: How many instruments does the song "Le Pop" use?

SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Le Pop"


Question: How many instrument does the musician with last name "Heilo" use?

Context: CREATE TABLE instruments (bandmateid VARCHAR); CREATE TABLE Band (id VARCHAR, lastname VARCHAR)

SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN Band AS T2 ON T1.bandmateid = T2.id WHERE T2.lastname = "Heilo"


Question: Find all the instruments ever used by the musician with last name "Heilo"?

SELECT instrument FROM instruments AS T1 JOIN Band AS T2 ON T1.bandmateid = T2.id WHERE T2.lastname = "Heilo"


Question: Which song has the most vocals?

Context: CREATE TABLE vocals (songid VARCHAR); CREATE TABLE songs (songid VARCHAR)

SELECT title FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid GROUP BY T1.songid ORDER BY COUNT(*) DESC LIMIT 1


Question: Which vocal type is the most frequently appearring type?

Context: CREATE TABLE vocals (TYPE VARCHAR)

SELECT TYPE FROM vocals GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: Which vocal type has the band mate with last name "Heilo" played the most?

Context: CREATE TABLE vocals (bandmate VARCHAR); CREATE TABLE band (id VARCHAR)

SELECT TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE lastname = "Heilo" GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the vocal types used in song "Le Pop"?

SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Le Pop"


Question: Find the number of vocal types used in song "Demon Kitty Rag"?

SELECT COUNT(*) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Demon Kitty Rag"


Question: How many songs have a lead vocal?

SELECT COUNT(DISTINCT title) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE TYPE = "lead"


Question: Which vocal type did the musician with first name "Solveig" played in the song with title "A Bar in Amsterdam"?

Context: CREATE TABLE vocals (songid VARCHAR, bandmate VARCHAR); CREATE TABLE band (id VARCHAR, firstname VARCHAR); CREATE TABLE songs (songid VARCHAR, title VARCHAR)

SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid JOIN band AS T3 ON T1.bandmate = T3.id WHERE T3.firstname = "Solveig" AND T2.title = "A Bar In Amsterdam"


Question: Find all the songs that do not have a lead vocal.

Context: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE vocals (songid VARCHAR)

SELECT DISTINCT title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid EXCEPT SELECT t2.title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid WHERE TYPE = "lead"


Question: Find all the vocal types.

Context: CREATE TABLE vocals (TYPE VARCHAR)


Question: What are the albums produced in year 2010?

Context: CREATE TABLE Albums (YEAR VARCHAR)


Question: Who performed the song named "Le Pop"?

SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Le Pop"


Question: What instrument did the musician with last name "Heilo" use in the song "Badlands"?

SELECT T4.instrument FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId JOIN Instruments AS T4 ON T4.songid = T3.songid AND T4.bandmateid = T2.id WHERE T2.lastname = "Heilo" AND T3.title = "Badlands"


Question: How many instruments does the song "Badlands" use?

SELECT COUNT(DISTINCT instrument) FROM instruments AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Badlands"


Question: What are the vocal types used in song "Badlands"?

SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Badlands"


Question: Find the number of vocal types used in song "Le Pop"

SELECT COUNT(*) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE title = "Le Pop"


Question: How many songs have a shared vocal?

SELECT COUNT(DISTINCT title) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE TYPE = "shared"


Question: Find all the songs that do not have a back vocal.

SELECT DISTINCT title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid EXCEPT SELECT t2.title FROM vocals AS t1 JOIN songs AS t2 ON t1.songid = t2.songid WHERE TYPE = "back"


Question: Which vocal type has the band mate with first name "Solveig" played the most?

SELECT TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE firstname = "Solveig" GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: Which vocal type did the musician with last name "Heilo" played in the song with title "Der Kapitan"?

Context: CREATE TABLE band (id VARCHAR, lastname VARCHAR); CREATE TABLE vocals (songid VARCHAR, bandmate VARCHAR); CREATE TABLE songs (songid VARCHAR, title VARCHAR)

SELECT TYPE FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid JOIN band AS T3 ON T1.bandmate = T3.id WHERE T3.lastname = "Heilo" AND T2.title = "Der Kapitan"


Question: Find the first name of the band mate that has performed in most songs.

Context: CREATE TABLE Songs (SongId VARCHAR); CREATE TABLE Band (firstname VARCHAR, id VARCHAR); CREATE TABLE Performance (bandmate VARCHAR)

SELECT t2.firstname FROM Performance AS t1 JOIN Band AS t2 ON t1.bandmate = t2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId GROUP BY firstname ORDER BY COUNT(*) DESC LIMIT 1


Question: Which vocal type has the band mate with first name "Marianne" played the most?

SELECT TYPE FROM vocals AS T1 JOIN band AS T2 ON T1.bandmate = T2.id WHERE firstname = "Marianne" GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: Who is performing in the back stage position for the song "Der Kapitan"? Show the first name and last name.

SELECT T2.firstname, T2.lastname FROM Performance AS T1 JOIN Band AS T2 ON T1.bandmate = T2.id JOIN Songs AS T3 ON T3.SongId = T1.SongId WHERE T3.Title = "Der Kapitan" AND T1.StagePosition = "back"


Question: What are the songs in album "A Kiss Before You Go: Live in Hamburg"?

Context: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR, title VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR)

SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE T1.title = "A Kiss Before You Go: Live in Hamburg"


Question: What are all the songs in albums under label "Universal Music Group"?

Context: CREATE TABLE songs (title VARCHAR, songid VARCHAR); CREATE TABLE albums (aid VARCHAR); CREATE TABLE tracklists (albumid VARCHAR, songid VARCHAR)

SELECT T3.title FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.label = "Universal Music Group"


Question: Find the number of songs in all the studio albums.

SELECT COUNT(DISTINCT T3.title) FROM albums AS T1 JOIN tracklists AS T2 ON T1.aid = T2.albumid JOIN songs AS T3 ON T2.songid = T3.songid WHERE t1.type = "Studio"


Question: Who is the founder of Sony?

Context: CREATE TABLE manufacturers (founder VARCHAR, name VARCHAR)

SELECT founder FROM manufacturers WHERE name = 'Sony'


Question: Where is the headquarter of the company founded by James?

Context: CREATE TABLE manufacturers (headquarter VARCHAR, founder VARCHAR)

SELECT headquarter FROM manufacturers WHERE founder = 'James'


Question: Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first.

Context: CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, revenue VARCHAR)

SELECT name, headquarter FROM manufacturers ORDER BY revenue DESC


Question: What are the average, maximum and total revenues of all companies?

Context: CREATE TABLE manufacturers (revenue INTEGER)

SELECT AVG(revenue), MAX(revenue), SUM(revenue) FROM manufacturers


Question: How many companies were created by Andy?

Context: CREATE TABLE manufacturers (founder VARCHAR)

SELECT COUNT(*) FROM manufacturers WHERE founder = 'Andy'


Question: Find the total revenue created by the companies whose headquarter is located at Austin.

Context: CREATE TABLE manufacturers (revenue INTEGER, headquarter VARCHAR)

SELECT SUM(revenue) FROM manufacturers WHERE headquarter = 'Austin'


Question: What are the different cities listed?

Context: CREATE TABLE manufacturers (headquarter VARCHAR)

SELECT DISTINCT headquarter FROM manufacturers


Question: Find the number of manufactures that are based in Tokyo or Beijing.

SELECT COUNT(*) FROM manufacturers WHERE headquarter = 'Tokyo' OR headquarter = 'Beijing'


Question: Find the founder of the company whose name begins with the letter 'S'.

SELECT founder FROM manufacturers WHERE name LIKE 'S%'


Question: Find the name of companies whose revenue is between 100 and 150.

Context: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER)

SELECT name FROM manufacturers WHERE revenue BETWEEN 100 AND 150


Question: What is the total revenue of all companies whose main office is at Tokyo or Taiwan?

Context: CREATE TABLE manufacturers (revenue INTEGER, Headquarter VARCHAR)

SELECT SUM(revenue) FROM manufacturers WHERE Headquarter = 'Tokyo' OR Headquarter = 'Taiwan'


Question: Find the name of product that is produced by both companies Creative Labs and Sony.

Context: CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)

SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Creative Labs' INTERSECT SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony'


Question: Find the name, headquarter and founder of the manufacturer that has the highest revenue.

Context: CREATE TABLE manufacturers (name VARCHAR, headquarter VARCHAR, founder VARCHAR, revenue VARCHAR)

SELECT name, headquarter, founder FROM manufacturers ORDER BY revenue DESC LIMIT 1


Question: Find the name, headquarter and revenue of all manufacturers sorted by their revenue in the descending order.

SELECT name, headquarter, revenue FROM manufacturers ORDER BY revenue DESC


Question: Find the name of companies whose revenue is greater than the average revenue of all companies.

SELECT name FROM manufacturers WHERE revenue > (SELECT AVG(revenue) FROM manufacturers)


Question: Find the name of companies whose revenue is smaller than the revenue of all companies based in Austin.

Context: CREATE TABLE manufacturers (name VARCHAR, revenue INTEGER, headquarter VARCHAR)

SELECT name FROM manufacturers WHERE revenue < (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin')


Question: Find the total revenue of companies whose revenue is larger than the revenue of some companies based in Austin.

SELECT SUM(revenue) FROM manufacturers WHERE revenue > (SELECT MIN(revenue) FROM manufacturers WHERE headquarter = 'Austin')


Question: Find the total revenue of companies of each founder.

Context: CREATE TABLE manufacturers (founder VARCHAR, revenue INTEGER)

SELECT SUM(revenue), founder FROM manufacturers GROUP BY founder


Question: Find the name and revenue of the company that earns the highest revenue in each city.

Context: CREATE TABLE manufacturers (name VARCHAR, Headquarter VARCHAR, revenue INTEGER)

SELECT name, MAX(revenue), Headquarter FROM manufacturers GROUP BY Headquarter


Question: Find the total revenue for each manufacturer.

SELECT SUM(revenue), name FROM manufacturers GROUP BY name


Question: Find the average prices of all products from each manufacture, and list each company's name.

Context: CREATE TABLE products (price INTEGER, Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR)

SELECT AVG(T1.price), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name


Question: Find the number of different products that are produced by companies at different headquarter cities.

Context: CREATE TABLE manufacturers (Headquarter VARCHAR, code VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)

SELECT COUNT(DISTINCT T1.name), T2.Headquarter FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.Headquarter


Question: Find number of products which Sony does not make.

Context: CREATE TABLE manufacturers (code VARCHAR, name VARCHAR); CREATE TABLE products (name VARCHAR); CREATE TABLE products (name VARCHAR, Manufacturer VARCHAR)

SELECT COUNT(DISTINCT name) FROM products WHERE NOT name IN (SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony')


Question: Find the name of companies that do not make DVD drive.

Context: CREATE TABLE manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Manufacturer VARCHAR, name VARCHAR); CREATE TABLE manufacturers (name VARCHAR)

SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T1.name = 'DVD drive'


Question: Find the number of products for each manufacturer, showing the name of each company.

Context: CREATE TABLE products (Manufacturer VARCHAR); CREATE TABLE manufacturers (name VARCHAR, code VARCHAR)

SELECT COUNT(*), T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name


Question: Select the names of all the products in the store.

Context: CREATE TABLE Products (Name VARCHAR)


Question: Select the names and the prices of all the products in the store.

Context: CREATE TABLE products (name VARCHAR, price VARCHAR)


Question: Select the name of the products with a price less than or equal to $200.

SELECT name FROM products WHERE price <= 200


Question: Find all information of all the products with a price between $60 and $120.

Context: CREATE TABLE products (price INTEGER)

SELECT * FROM products WHERE price BETWEEN 60 AND 120


Question: Compute the average price of all the products.

Context: CREATE TABLE products (price INTEGER)


Question: Compute the average price of all products with manufacturer code equal to 2.

Context: CREATE TABLE products (price INTEGER, Manufacturer VARCHAR)

SELECT AVG(price) FROM products WHERE Manufacturer = 2


Question: Compute the number of products with a price larger than or equal to $180.

Context: CREATE TABLE products (price VARCHAR)

SELECT COUNT(*) FROM products WHERE price >= 180


Question: Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name  (in ascending order).

SELECT name, price FROM products WHERE price >= 180 ORDER BY price DESC, name


Question: Select all the data from the products and each product's manufacturer.

Context: CREATE TABLE products (manufacturer VARCHAR); CREATE TABLE Manufacturers (code VARCHAR)

SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code


Question: Select the average price of each manufacturer's products, showing only the manufacturer's code.

Context: CREATE TABLE Products (Manufacturer VARCHAR, Price INTEGER)

SELECT AVG(Price), Manufacturer FROM Products GROUP BY Manufacturer


Question: Select the average price of each manufacturer's products, showing the manufacturer's name.

Context: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR)

SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name


Question: Select the names of manufacturer whose products have an average price higher than or equal to $150.

Context: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Price INTEGER, manufacturer VARCHAR, price INTEGER)

SELECT AVG(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING AVG(T1.price) >= 150


Question: Select the name and price of the cheapest product.

Context: CREATE TABLE Products (name VARCHAR, price VARCHAR)

SELECT name, price FROM Products ORDER BY price LIMIT 1


Question: Select the name of each manufacturer along with the name and price of its most expensive product.

Context: CREATE TABLE Manufacturers (name VARCHAR, code VARCHAR); CREATE TABLE products (Name VARCHAR, Price INTEGER, manufacturer VARCHAR)

SELECT T1.Name, MAX(T1.Price), T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name


Question: Select the code of the product that is cheapest in each product category.

Context: CREATE TABLE products (code VARCHAR, name VARCHAR, price INTEGER)

SELECT code, name, MIN(price) FROM products GROUP BY name


Question: What is the id of the problem log that is created most recently?

Context: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR)

SELECT problem_log_id FROM problem_log ORDER BY log_entry_date DESC LIMIT 1


Question: What is the oldest log id and its corresponding problem id?

Context: CREATE TABLE problem_log (problem_log_id VARCHAR, problem_id VARCHAR, log_entry_date VARCHAR)

SELECT problem_log_id, problem_id FROM problem_log ORDER BY log_entry_date LIMIT 1


Question: Find all the ids and dates of the logs for the problem whose id is 10.

Context: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_date VARCHAR, problem_id VARCHAR)

SELECT problem_log_id, log_entry_date FROM problem_log WHERE problem_id = 10


Question: List all the log ids and their descriptions from the problem logs.

Context: CREATE TABLE problem_log (problem_log_id VARCHAR, log_entry_description VARCHAR)

SELECT problem_log_id, log_entry_description FROM problem_log


Question: List the first and last names of all distinct staff members who are assigned to the problem whose id is 1.

Context: CREATE TABLE problem_log (assigned_to_staff_id VARCHAR, problem_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR)

SELECT DISTINCT staff_first_name, staff_last_name FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T2.problem_id = 1


Question: List the problem id and log id which are assigned to the staff named Rylan Homenick.

Context: CREATE TABLE problem_log (problem_id VARCHAR, problem_log_id VARCHAR, assigned_to_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR)

SELECT DISTINCT T2.problem_id, T2.problem_log_id FROM staff AS T1 JOIN problem_log AS T2 ON T1.staff_id = T2.assigned_to_staff_id WHERE T1.staff_first_name = "Rylan" AND T1.staff_last_name = "Homenick"


Question: How many problems are there for product voluptatem?

Context: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR)

SELECT COUNT(*) FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id WHERE T1.product_name = "voluptatem"


Question: How many problems does the product with the most problems have? List the number of the problems and product name.

Context: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_name VARCHAR, product_id VARCHAR)

SELECT COUNT(*), T1.product_name FROM product AS T1 JOIN problems AS T2 ON T1.product_id = T2.product_id GROUP BY T1.product_name ORDER BY COUNT(*) DESC LIMIT 1


Question: Give me a list of descriptions of the problems that are reported by the staff whose first name is Christop.

Context: CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR); CREATE TABLE problems (problem_description VARCHAR, reported_by_staff_id VARCHAR)

SELECT T1.problem_description FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop"


Question: Find the ids of the problems that are reported by the staff whose last name is Bosco.

Context: CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_last_name VARCHAR)

SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_last_name = "Bosco"


Question: What are the ids of the problems which are reported after 1978-06-26?

Context: CREATE TABLE problems (problem_id VARCHAR, date_problem_reported INTEGER)

SELECT problem_id FROM problems WHERE date_problem_reported > "1978-06-26"


Question: What are the ids of the problems which are reported before 1978-06-26?

SELECT problem_id FROM problems WHERE date_problem_reported < "1978-06-26"


Question: For each product which has problems, what are the number of problems and the product id?

Context: CREATE TABLE problems (product_id VARCHAR); CREATE TABLE product (product_id VARCHAR)

SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_id


Question: For each product that has problems, find the number of problems reported after 1986-11-13 and the product id?

Context: CREATE TABLE product (product_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, date_problem_reported INTEGER)

SELECT COUNT(*), T2.product_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T1.date_problem_reported > "1986-11-13" GROUP BY T2.product_id


Question: List the names of all the distinct product names in alphabetical order?

Context: CREATE TABLE product (product_name VARCHAR)

SELECT DISTINCT product_name FROM product ORDER BY product_name


Question: List all the distinct product names ordered by product id?

Context: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR)

SELECT DISTINCT product_name FROM product ORDER BY product_id


Question: What are the id of problems reported by the staff named Dameon Frami or Jolie Weber?

Context: CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR)

SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Dameon" AND T2.staff_last_name = "Frami" UNION SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Jolie" AND T2.staff_last_name = "Weber"


Question: What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?

Context: CREATE TABLE problems (reported_by_staff_id VARCHAR, closure_authorised_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR)

SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst"


Question: What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte?

Context: CREATE TABLE problems (problem_id VARCHAR, reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (reported_by_staff_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR)

SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < (SELECT MIN(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte")


Question: What are the ids of the problems reported after the date of any problems reported by Rylan Homenick?

SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported > (SELECT MAX(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Rylan" AND T4.staff_last_name = "Homenick")


Question: Find the top 3 products which have the largest number of problems?

SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id GROUP BY T2.product_name ORDER BY COUNT(*) DESC LIMIT 3


Question: List the ids of the problems from the product "voluptatem" that are reported after 1995?

Context: CREATE TABLE problems (problem_id VARCHAR, product_id VARCHAR, date_problem_reported VARCHAR); CREATE TABLE product (product_id VARCHAR, product_name VARCHAR)

SELECT T1.problem_id FROM problems AS T1 JOIN product AS T2 ON T1.product_id = T2.product_id WHERE T2.product_name = "voluptatem" AND T1.date_problem_reported > "1995"


Question: Find the first and last name of the staff members who reported problems from the product "rem" but not "aut"?

Context: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_first_name VARCHAR, staff_last_name VARCHAR, staff_id VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR)

SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "rem" EXCEPT SELECT T3.staff_first_name, T3.staff_last_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T2.product_name = "aut"


Question: Find the products which have problems reported by both Lacey Bosco and Kenton Champlin?

Context: CREATE TABLE product (product_name VARCHAR, product_id VARCHAR); CREATE TABLE staff (staff_id VARCHAR, staff_first_name VARCHAR, staff_last_name VARCHAR); CREATE TABLE problems (product_id VARCHAR, reported_by_staff_id VARCHAR)

SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin"


Question: How many branches where have more than average number of memberships are there?

Context: CREATE TABLE branch (membership_amount INTEGER)

SELECT COUNT(*) FROM branch WHERE membership_amount > (SELECT AVG(membership_amount) FROM branch)


Question: Show name, address road, and city for all branches sorted by open year.

Context: CREATE TABLE branch (name VARCHAR, address_road VARCHAR, city VARCHAR, open_year VARCHAR)

SELECT name, address_road, city FROM branch ORDER BY open_year


Question: What are names for top three branches with most number of membership?

Context: CREATE TABLE branch (name VARCHAR, membership_amount VARCHAR)

SELECT name FROM branch ORDER BY membership_amount DESC LIMIT 3


Question: Show all distinct city where branches with at least 100 memberships are located.

Context: CREATE TABLE branch (city VARCHAR, membership_amount VARCHAR)

SELECT DISTINCT city FROM branch WHERE membership_amount >= 100


Question: List all open years when at least two shops are opened.

Context: CREATE TABLE branch (open_year VARCHAR)

SELECT open_year FROM branch GROUP BY open_year HAVING COUNT(*) >= 2


Question: Show minimum and maximum amount of memberships for all branches opened in 2011 or located at city London.

Context: CREATE TABLE branch (membership_amount INTEGER, open_year VARCHAR, city VARCHAR)

SELECT MIN(membership_amount), MAX(membership_amount) FROM branch WHERE open_year = 2011 OR city = 'London'


Question: Show the city and the number of branches opened before 2010 for each city.

Context: CREATE TABLE branch (city VARCHAR, open_year INTEGER)

SELECT city, COUNT(*) FROM branch WHERE open_year < 2010 GROUP BY city


Question: How many different levels do members have?

Context: CREATE TABLE member (LEVEL VARCHAR)

SELECT COUNT(DISTINCT LEVEL) FROM member


Question: Show card number, name, and hometown for all members in a descending order of level.

Context: CREATE TABLE member (card_number VARCHAR, name VARCHAR, hometown VARCHAR, LEVEL VARCHAR)

SELECT card_number, name, hometown FROM member ORDER BY LEVEL DESC


Question: Show the membership level with most number of members.

Context: CREATE TABLE member (LEVEL VARCHAR)

SELECT LEVEL FROM member GROUP BY LEVEL ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all member names and registered branch names sorted by register year.

Context: CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR)

SELECT T3.name, T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id ORDER BY T1.register_year


Question: Show all branch names with the number of members in each branch registered after 2015.

Context: CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year INTEGER)

SELECT T2.name, COUNT(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year > 2015 GROUP BY T2.branch_id


Question: Show member names without any registered branch.

Context: CREATE TABLE member (name VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (name VARCHAR, member_id VARCHAR)

SELECT name FROM member WHERE NOT member_id IN (SELECT member_id FROM membership_register_branch)


Question: List the branch name and city without any registered members.

Context: CREATE TABLE membership_register_branch (name VARCHAR, city VARCHAR, branch_id VARCHAR); CREATE TABLE branch (name VARCHAR, city VARCHAR, branch_id VARCHAR)

SELECT name, city FROM branch WHERE NOT branch_id IN (SELECT branch_id FROM membership_register_branch)


Question: What is the name and open year for the branch with most number of memberships registered in 2016?

Context: CREATE TABLE membership_register_branch (branch_id VARCHAR, register_year VARCHAR); CREATE TABLE branch (name VARCHAR, open_year VARCHAR, branch_id VARCHAR)

SELECT T2.name, T2.open_year FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T1.register_year = 2016 GROUP BY T2.branch_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the member name and hometown who registered a branch in 2016.

Context: CREATE TABLE member (name VARCHAR, hometown VARCHAR, member_id VARCHAR); CREATE TABLE membership_register_branch (member_id VARCHAR, register_year VARCHAR)

SELECT T2.name, T2.hometown FROM membership_register_branch AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T1.register_year = 2016


Question: Show all city with a branch opened in 2001 and a branch with more than 100 membership.

Context: CREATE TABLE branch (city VARCHAR, open_year VARCHAR, membership_amount VARCHAR)

SELECT city FROM branch WHERE open_year = 2001 AND membership_amount > 100


Question: Show all cities without a branch having more than 100 memberships.

Context: CREATE TABLE branch (city VARCHAR, membership_amount INTEGER)

SELECT city FROM branch EXCEPT SELECT city FROM branch WHERE membership_amount > 100


Question: What is the sum of total pounds of purchase in year 2018 for all branches in London?

Context: CREATE TABLE purchase (branch_id VARCHAR, year VARCHAR); CREATE TABLE branch (branch_id VARCHAR, city VARCHAR)

SELECT SUM(total_pounds) FROM purchase AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id WHERE T2.city = 'London' AND T1.year = 2018


Question: What is the total number of purchases for members with level 6?

Context: CREATE TABLE member (member_id VARCHAR, level VARCHAR); CREATE TABLE purchase (member_id VARCHAR)

SELECT COUNT(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6


Question: Find the name of branches where have some members whose hometown is in Louisville, Kentucky and some in Hiram, Georgia.

Context: CREATE TABLE member (member_id VARCHAR, Hometown VARCHAR); CREATE TABLE branch (name VARCHAR, branch_id VARCHAR); CREATE TABLE membership_register_branch (branch_id VARCHAR, member_id VARCHAR)

SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Louisville ,  Kentucky' INTERSECT SELECT T2.name FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.branch_id = T2.branch_id JOIN member AS T3 ON T1.member_id = T3.member_id WHERE T3.Hometown = 'Hiram ,  Georgia'


Question: list the card number of all members whose hometown address includes word "Kentucky".

Context: CREATE TABLE member (card_number VARCHAR, Hometown VARCHAR)

SELECT card_number FROM member WHERE Hometown LIKE "%Kentucky%"


Question: Find the number of students in total.

Context: CREATE TABLE STUDENT (Id VARCHAR)


Question: Find the number of voting records in total.

Context: CREATE TABLE VOTING_RECORD (Id VARCHAR)


Question: Find the distinct number of president votes.

Context: CREATE TABLE VOTING_RECORD (President_Vote VARCHAR)

SELECT COUNT(DISTINCT President_Vote) FROM VOTING_RECORD


Question: Find the maximum age of all the students.

Context: CREATE TABLE STUDENT (Age INTEGER)


Question: Find the last names of students with major 50.

Context: CREATE TABLE STUDENT (LName VARCHAR, Major VARCHAR)

SELECT LName FROM STUDENT WHERE Major = 50


Question: Find the first names of students with age above 22.

Context: CREATE TABLE STUDENT (Fname VARCHAR, Age INTEGER)

SELECT Fname FROM STUDENT WHERE Age > 22


Question: What are the majors of male (sex is M) students?

Context: CREATE TABLE STUDENT (Major VARCHAR, Sex VARCHAR)

SELECT Major FROM STUDENT WHERE Sex = "M"


Question: What is the average age of female (sex is F) students?

Context: CREATE TABLE STUDENT (Age INTEGER, Sex VARCHAR)

SELECT AVG(Age) FROM STUDENT WHERE Sex = "F"


Question: What are the maximum and minimum age of students with major 600?

Context: CREATE TABLE STUDENT (Age INTEGER, Major VARCHAR)

SELECT MAX(Age), MIN(Age) FROM STUDENT WHERE Major = 600


Question: Who are the advisors for students that live in a city with city code "BAL"?

Context: CREATE TABLE STUDENT (Advisor VARCHAR, city_code VARCHAR)

SELECT Advisor FROM STUDENT WHERE city_code = "BAL"


Question: What are the distinct secretary votes in the fall election cycle?

Context: CREATE TABLE VOTING_RECORD (Secretary_Vote VARCHAR, ELECTION_CYCLE VARCHAR)

SELECT DISTINCT Secretary_Vote FROM VOTING_RECORD WHERE ELECTION_CYCLE = "Fall"


Question: What are the distinct president votes on 08/30/2015?

Context: CREATE TABLE VOTING_RECORD (PRESIDENT_Vote VARCHAR, Registration_Date VARCHAR)

SELECT DISTINCT PRESIDENT_Vote FROM VOTING_RECORD WHERE Registration_Date = "08/30/2015"


Question: Report the distinct registration date and the election cycle.

Context: CREATE TABLE VOTING_RECORD (Registration_Date VARCHAR, Election_Cycle VARCHAR)

SELECT DISTINCT Registration_Date, Election_Cycle FROM VOTING_RECORD


Question: Report the distinct president vote and the vice president vote.

Context: CREATE TABLE VOTING_RECORD (President_Vote VARCHAR, VICE_President_Vote VARCHAR)

SELECT DISTINCT President_Vote, VICE_President_Vote FROM VOTING_RECORD


Question: Find the distinct last names of the students who have class president votes.

Context: CREATE TABLE STUDENT (LName VARCHAR, StuID VARCHAR); CREATE TABLE VOTING_RECORD (CLASS_President_VOTE VARCHAR)

SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.CLASS_President_VOTE


Question: Find the distinct first names of the students who have class senator votes.

Context: CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE VOTING_RECORD (CLASS_Senator_VOTE VARCHAR)

SELECT DISTINCT T1.Fname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.CLASS_Senator_VOTE


Question: Find the distinct ages of students who have secretary votes in the fall election cycle.

Context: CREATE TABLE VOTING_RECORD (Secretary_Vote VARCHAR, Election_Cycle VARCHAR); CREATE TABLE STUDENT (Age VARCHAR, StuID VARCHAR)

SELECT DISTINCT T1.Age FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.Secretary_Vote WHERE T2.Election_Cycle = "Fall"


Question: Find the distinct Advisor of students who have treasurer votes in the spring election cycle.

Context: CREATE TABLE STUDENT (Advisor VARCHAR, StuID VARCHAR); CREATE TABLE VOTING_RECORD (Treasurer_Vote VARCHAR, Election_Cycle VARCHAR)

SELECT DISTINCT T1.Advisor FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.Treasurer_Vote WHERE T2.Election_Cycle = "Spring"


Question: Find the distinct majors of students who have treasurer votes.

Context: CREATE TABLE VOTING_RECORD (Treasurer_Vote VARCHAR); CREATE TABLE STUDENT (Major VARCHAR, StuID VARCHAR)

SELECT DISTINCT T1.Major FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.Treasurer_Vote


Question: Find the first and last names of all the female (sex is F) students who have president votes.

Context: CREATE TABLE STUDENT (Fname VARCHAR, LName VARCHAR, StuID VARCHAR, sex VARCHAR); CREATE TABLE VOTING_RECORD (President_VOTE VARCHAR)

SELECT DISTINCT T1.Fname, T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.President_VOTE WHERE T1.sex = "F"


Question: Find the first and last name of all the students of age 18 who have vice president votes.

Context: CREATE TABLE STUDENT (Fname VARCHAR, LName VARCHAR, StuID VARCHAR, age VARCHAR); CREATE TABLE VOTING_RECORD (VICE_President_VOTE VARCHAR)

SELECT DISTINCT T1.Fname, T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.VICE_President_VOTE WHERE T1.age = 18


Question: How many male (sex is M) students have class senator votes in the fall election cycle?

Context: CREATE TABLE VOTING_RECORD (Election_Cycle VARCHAR); CREATE TABLE STUDENT (StuID VARCHAR, Sex VARCHAR)

SELECT COUNT(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = Class_Senator_Vote WHERE T1.Sex = "M" AND T2.Election_Cycle = "Fall"


Question: Find the number of students whose city code is NYC and who have class senator votes in the spring election cycle.

Context: CREATE TABLE STUDENT (StuID VARCHAR, city_code VARCHAR); CREATE TABLE VOTING_RECORD (Election_Cycle VARCHAR)

SELECT COUNT(*) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = Class_Senator_Vote WHERE T1.city_code = "NYC" AND T2.Election_Cycle = "Spring"


Question: Find the average age of students who live in the city with code "NYC" and have secretary votes in the spring election cycle.

Context: CREATE TABLE STUDENT (Age INTEGER, StuID VARCHAR, city_code VARCHAR); CREATE TABLE VOTING_RECORD (Election_Cycle VARCHAR)

SELECT AVG(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = SECRETARY_Vote WHERE T1.city_code = "NYC" AND T2.Election_Cycle = "Spring"


Question: Find the average age of female (sex is F) students who have secretary votes in the spring election cycle.

Context: CREATE TABLE STUDENT (Age INTEGER, StuID VARCHAR, Sex VARCHAR); CREATE TABLE VOTING_RECORD (Election_Cycle VARCHAR)

SELECT AVG(T1.Age) FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = SECRETARY_Vote WHERE T1.Sex = "F" AND T2.Election_Cycle = "Spring"


Question: Find the distinct first names of all the students who have vice president votes and whose city code is not PIT.

Context: CREATE TABLE STUDENT (Fname VARCHAR, city_code VARCHAR); CREATE TABLE STUDENT (Fname VARCHAR, StuID VARCHAR); CREATE TABLE VOTING_RECORD (VICE_PRESIDENT_Vote VARCHAR)

SELECT DISTINCT T1.Fname FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = T2.VICE_PRESIDENT_Vote EXCEPT SELECT DISTINCT Fname FROM STUDENT WHERE city_code = "PIT"


Question: Find the distinct last names of all the students who have president votes and whose advisor is not 2192.

Context: CREATE TABLE STUDENT (LName VARCHAR, PRESIDENT_Vote VARCHAR, Advisor VARCHAR); CREATE TABLE STUDENT (LName VARCHAR, StuID VARCHAR); CREATE TABLE VOTING_RECORD (Id VARCHAR)

SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = PRESIDENT_Vote EXCEPT SELECT DISTINCT LName FROM STUDENT WHERE Advisor = "2192"


Question: Find the distinct last names of all the students who have president votes and whose advisor is 8741.

SELECT DISTINCT T1.LName FROM STUDENT AS T1 JOIN VOTING_RECORD AS T2 ON T1.StuID = PRESIDENT_Vote INTERSECT SELECT DISTINCT LName FROM STUDENT WHERE Advisor = "8741"


Question: For each advisor, report the total number of students advised by him or her.

Context: CREATE TABLE STUDENT (Advisor VARCHAR)

SELECT Advisor, COUNT(*) FROM STUDENT GROUP BY Advisor


Question: Report all advisors that advise more than 2 students.

Context: CREATE TABLE STUDENT (Advisor VARCHAR)

SELECT Advisor FROM STUDENT GROUP BY Advisor HAVING COUNT(*) > 2


Question: Report all majors that have less than 3 students.

Context: CREATE TABLE STUDENT (Major VARCHAR)

SELECT Major FROM STUDENT GROUP BY Major HAVING COUNT(*) < 3


Question: For each election cycle, report the number of voting records.

Context: CREATE TABLE VOTING_RECORD (Election_Cycle VARCHAR)

SELECT Election_Cycle, COUNT(*) FROM VOTING_RECORD GROUP BY Election_Cycle


Question: Which major has the most students?

Context: CREATE TABLE STUDENT (Major VARCHAR, major VARCHAR)

SELECT Major FROM STUDENT GROUP BY major ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the most common major among female (sex is F) students?

Context: CREATE TABLE STUDENT (Major VARCHAR, major VARCHAR, Sex VARCHAR)

SELECT Major FROM STUDENT WHERE Sex = "F" GROUP BY major ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the city_code of the city that the most students live in?

Context: CREATE TABLE STUDENT (city_code VARCHAR)

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


Question: How many products are there?

Context: CREATE TABLE products (Id VARCHAR)


Question: How many colors are there?

Context: CREATE TABLE ref_colors (Id VARCHAR)


Question: How many characteristics are there?

Context: CREATE TABLE CHARACTERISTICS (Id VARCHAR)


Question: What are the names and buying prices of all the products?

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

SELECT product_name, typical_buying_price FROM products


Question: List the description of all the colors.

Context: CREATE TABLE ref_colors (color_description VARCHAR)

SELECT color_description FROM ref_colors


Question: Find the names of all the product characteristics.

Context: CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR)

SELECT DISTINCT characteristic_name FROM CHARACTERISTICS


Question: What are the names of products with category "Spices"?

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

SELECT product_name FROM products WHERE product_category_code = "Spices"


Question: List the names, color descriptions and product descriptions of products with category "Herbs".

Context: CREATE TABLE Ref_colors (color_description VARCHAR, color_code VARCHAR); CREATE TABLE products (product_name VARCHAR, product_description VARCHAR, color_code VARCHAR)

SELECT T1.product_name, T2.color_description, T1.product_description FROM products AS T1 JOIN Ref_colors AS T2 ON T1.color_code = T2.color_code WHERE product_category_code = "Herbs"


Question: How many products are there under the category "Seeds"?

Context: CREATE TABLE products (product_category_code VARCHAR)

SELECT COUNT(*) FROM products WHERE product_category_code = "Seeds"


Question: Find the number of products with category "Spices" and typically sold above 1000.

Context: CREATE TABLE products (product_category_code VARCHAR, typical_buying_price VARCHAR)

SELECT COUNT(*) FROM products WHERE product_category_code = "Spices" AND typical_buying_price > 1000


Question: What is the category and typical buying price  of the product with name "cumin"?

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

SELECT product_category_code, typical_buying_price FROM products WHERE product_name = "cumin"


Question: Which category does the product named "flax" belong to?

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

SELECT product_category_code FROM products WHERE product_name = "flax"


Question: What is the name of the product with the color description 'yellow'?

Context: CREATE TABLE ref_colors (color_code VARCHAR, color_description VARCHAR); CREATE TABLE products (product_name VARCHAR, color_code VARCHAR)

SELECT T1.product_name FROM products AS T1 JOIN ref_colors AS T2 ON T1.color_code = T2.color_code WHERE T2.color_description = 'yellow'


Question: Find the category descriptions of the products whose descriptions include letter 't'.

Context: CREATE TABLE ref_product_categories (product_category_description VARCHAR, product_category_code VARCHAR); CREATE TABLE products (product_category_code VARCHAR, product_description VARCHAR)

SELECT T1.product_category_description FROM ref_product_categories AS T1 JOIN products AS T2 ON T1.product_category_code = T2.product_category_code WHERE T2.product_description LIKE '%t%'


Question: What is the color description of the product with name "catnip"?

Context: CREATE TABLE products (color_code VARCHAR, product_name VARCHAR); CREATE TABLE ref_colors (color_description VARCHAR, color_code VARCHAR)

SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code WHERE t1.product_name = "catnip"


Question: What is the color code and description of the product named "chervil"?

SELECT t1.color_code, t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code WHERE t1.product_name = "chervil"


Question: Find the id and color description of the products with at least 2 characteristics.

Context: CREATE TABLE product_characteristics (product_id VARCHAR); CREATE TABLE ref_colors (color_description VARCHAR, color_code VARCHAR); CREATE TABLE products (product_id VARCHAR, color_code VARCHAR)

SELECT t1.product_id, t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code JOIN product_characteristics AS t3 ON t1.product_id = t3.product_id GROUP BY t1.product_id HAVING COUNT(*) >= 2


Question: List all the product names with the color description "white".

SELECT t1.product_name FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code WHERE t2.color_description = "white"


Question: What are the name and typical buying and selling prices of the products that have color described as "yellow"?

Context: CREATE TABLE ref_colors (color_code VARCHAR, color_description VARCHAR); CREATE TABLE products (product_name VARCHAR, typical_buying_price VARCHAR, typical_selling_price VARCHAR, color_code VARCHAR)

SELECT t1.product_name, t1.typical_buying_price, t1.typical_selling_price FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code WHERE t2.color_description = "yellow"


Question: How many characteristics does the product named "sesame" have?

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

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id WHERE t1.product_name = "sesame"


Question: How many distinct characteristic names does the product "cumin" have?

Context: CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, characteristic_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT COUNT(DISTINCT t3.characteristic_name) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "sesame"


Question: What are all the characteristic names of product "sesame"?

SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "sesame"


Question: List all the characteristic names and data types of product "cumin".

Context: CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, characteristic_data_type VARCHAR, characteristic_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT t3.characteristic_name, t3.characteristic_data_type FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "cumin"


Question: List all characteristics of product named "sesame" with type code "Grade".

Context: CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, characteristic_id VARCHAR, characteristic_type_code VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "sesame" AND t3.characteristic_type_code = "Grade"


Question: How many characteristics does the product named "laurel" have?

Context: CREATE TABLE CHARACTERISTICS (characteristic_id VARCHAR); CREATE TABLE products (product_id VARCHAR, product_name VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "laurel"


Question: Find the number of characteristics that the product "flax" has.

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "flax"


Question: Find the name of the products that have the color description "red" and have the characteristic name "fast".

Context: CREATE TABLE CHARACTERISTICS (characteristic_id VARCHAR, characteristic_name VARCHAR); CREATE TABLE ref_colors (color_code VARCHAR, color_description VARCHAR); CREATE TABLE products (product_id VARCHAR, color_code VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT product_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "red" AND t3.characteristic_name = "fast"


Question: How many products have the characteristic named "hot"?

Context: CREATE TABLE products (product_id VARCHAR); CREATE TABLE CHARACTERISTICS (characteristic_id VARCHAR, characteristic_name VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t3.characteristic_name = "hot"


Question: List the all the distinct names of the products with the characteristic name 'warm'.

Context: CREATE TABLE CHARACTERISTICS (characteristic_id VARCHAR, characteristic_name VARCHAR); CREATE TABLE products (product_name VARCHAR, product_id VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT DISTINCT t1.product_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t3.characteristic_name = "warm"


Question: Find the number of the products that have their color described as "red" and have a characteristic named "slow".

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "red" AND t3.characteristic_name = "slow"


Question: Count the products that have the color description "white" or have the characteristic name "hot".

SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "white" OR t3.characteristic_name = "hot"


Question: What is the unit of measuerment of the product category code "Herbs"?

Context: CREATE TABLE ref_product_categories (unit_of_measure VARCHAR, product_category_code VARCHAR)

SELECT unit_of_measure FROM ref_product_categories WHERE product_category_code = "Herbs"


Question: Find the product category description of the product category with code "Spices".

Context: CREATE TABLE ref_product_categories (product_category_description VARCHAR, product_category_code VARCHAR)

SELECT product_category_description FROM ref_product_categories WHERE product_category_code = "Spices"


Question: What is the product category description and unit of measurement of category "Herbs"?

Context: CREATE TABLE ref_product_categories (product_category_description VARCHAR, unit_of_measure VARCHAR, product_category_code VARCHAR)

SELECT product_category_description, unit_of_measure FROM ref_product_categories WHERE product_category_code = "Herbs"


Question: What is the unit of measurement of product named "cumin"?

Context: CREATE TABLE ref_product_categories (unit_of_measure VARCHAR, product_category_code VARCHAR); CREATE TABLE products (product_category_code VARCHAR, product_name VARCHAR)

SELECT t2.unit_of_measure FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code = t2.product_category_code WHERE t1.product_name = "cumin"


Question: Find the unit of measurement and product category code of product named "chervil".

SELECT t2.unit_of_measure, t2.product_category_code FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code = t2.product_category_code WHERE t1.product_name = "chervil"


Question: Find the product names that are colored 'white' but do not have unit of measurement "Handful".

Context: CREATE TABLE products (product_name VARCHAR, product_category_code VARCHAR, color_code VARCHAR); CREATE TABLE ref_colors (color_code VARCHAR, color_description VARCHAR); CREATE TABLE ref_product_categories (product_category_code VARCHAR, unit_of_measure VARCHAR)

SELECT t1.product_name FROM products AS t1 JOIN ref_product_categories AS t2 ON t1.product_category_code = t2.product_category_code JOIN ref_colors AS t3 ON t1.color_code = t3.color_code WHERE t3.color_description = "white" AND t2.unit_of_measure <> "Handful"


Question: What is the description of the color for most products?

Context: CREATE TABLE ref_colors (color_description VARCHAR, color_code VARCHAR); CREATE TABLE products (color_code VARCHAR)

SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code GROUP BY t2.color_description ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the description of the color used by least products?

SELECT t2.color_description FROM products AS t1 JOIN ref_colors AS t2 ON t1.color_code = t2.color_code GROUP BY t2.color_description ORDER BY COUNT(*) LIMIT 1


Question: What is the characteristic name used by most number of the products?

Context: CREATE TABLE products (product_id VARCHAR); CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, characteristic_id VARCHAR); CREATE TABLE product_characteristics (product_id VARCHAR, characteristic_id VARCHAR)

SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id GROUP BY t3.characteristic_name ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names, details and data types of the characteristics which are never used by any product?

Context: CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, other_characteristic_details VARCHAR, characteristic_data_type VARCHAR, characteristic_id VARCHAR); CREATE TABLE product_characteristics (characteristic_id VARCHAR); CREATE TABLE CHARACTERISTICS (characteristic_name VARCHAR, other_characteristic_details VARCHAR, characteristic_data_type VARCHAR)

SELECT characteristic_name, other_characteristic_details, characteristic_data_type FROM CHARACTERISTICS EXCEPT SELECT t1.characteristic_name, t1.other_characteristic_details, t1.characteristic_data_type FROM CHARACTERISTICS AS t1 JOIN product_characteristics AS t2 ON t1.characteristic_id = t2.characteristic_id


Question: What are characteristic names used at least twice across all products?

SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id GROUP BY t3.characteristic_name HAVING COUNT(*) >= 2


Question: How many colors are never used by any product?

Context: CREATE TABLE products (color_code VARCHAR); CREATE TABLE Ref_colors (color_code VARCHAR)

SELECT COUNT(*) FROM Ref_colors WHERE NOT color_code IN (SELECT color_code FROM products)


Question: How many events are there?

Context: CREATE TABLE event (Id VARCHAR)


Question: List all the event names by year from the most recent to the oldest.

Context: CREATE TABLE event (name VARCHAR, YEAR VARCHAR)

SELECT name FROM event ORDER BY YEAR DESC


Question: What is the name of the event that happened in the most recent year?

SELECT name FROM event ORDER BY YEAR DESC LIMIT 1


Question: How many stadiums are there?

Context: CREATE TABLE stadium (Id VARCHAR)


Question: Find the name of the stadium that has the maximum capacity.

Context: CREATE TABLE stadium (name VARCHAR, capacity VARCHAR)

SELECT name FROM stadium ORDER BY capacity DESC LIMIT 1


Question: Find the names of stadiums whose capacity is smaller than the average capacity.

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

SELECT name FROM stadium WHERE capacity < (SELECT AVG(capacity) FROM stadium)


Question: Find the country that has the most stadiums.

Context: CREATE TABLE stadium (country VARCHAR)

SELECT country FROM stadium GROUP BY country ORDER BY COUNT(*) DESC LIMIT 1


Question: Which country has at most 3 stadiums listed?

Context: CREATE TABLE stadium (country VARCHAR)

SELECT country FROM stadium GROUP BY country HAVING COUNT(*) <= 3


Question: Which country has both stadiums with capacity greater than 60000 and stadiums with capacity less than 50000?

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

SELECT country FROM stadium WHERE capacity > 60000 INTERSECT SELECT country FROM stadium WHERE capacity < 50000


Question: How many cities have a stadium that was opened before the year of 2006?

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

SELECT COUNT(DISTINCT city) FROM stadium WHERE opening_year < 2006