db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
SQL
stringlengths
23
804
question_id
int64
0
9.43k
difficulty
stringclasses
1 value
sales
What is the average number of customers per sales person?
average = DIVIDE(COUNT(CustomerID), COUNT(EmployeeID));
SELECT CAST(COUNT(T1.CustomerID) AS REAL) / COUNT(T3.EmployeeID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID
5,400
sales
Among all customers handled by Innes E. del Castillo, how many have purchased Short-Sleeve Classic Jersey, L?
Short-Sleeve Classic Jersey, L' is name of product;
SELECT COUNT(T2.CustomerID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T3.FirstName = 'Innes' AND T3.LastName = 'del Castillo' AND T1.Name = 'Short-Sleeve Classic Jersey, L' AND T3.MiddleInitial = 'e'
5,401
sales
Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48.
name of the sales person = FirstName, MiddleInitial, LastName; 'Road-250 Black, 48' is name of product;
SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID INNER JOIN Customers AS T4 ON T2.CustomerID = T4.CustomerID WHERE T4.MiddleInitial = 'A' AND T4.LastName = 'White' AND T1.Name = 'Road-250 Black, 48' AND T4.FirstName = 'Elizabeth'
5,402
sales
How many sales people managed to sell Headlights - Weatherproof?
Headlights - Weatherproof' is name of product
SELECT COUNT(T2.SalesPersonID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Headlights - Weatherproof'
5,403
sales
Calculate the revenue produced through sales of HL Road Frame - Red, 56.
revenue = MULTIPLY(SUM(Quantity, Price)); 'HL Road Frame - Red, 56' is name of product;
SELECT SUM(T2.Quantity * T1.Price) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Road Frame - Red, 56'
5,404
sales
How many sales transactions were given by the customer named Joe L. Lopez?
sales transactions refers to SalesID;
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Joe' AND T2.MiddleInitial = 'L' AND T2.LastName = 'Lopez'
5,405
sales
Name the customers who received 'Touring Rim' as a free gift.
name of the customer = FirstName, MiddleInitial, LastName; 'Touring Rim' is name of product;
SELECT DISTINCT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T3.Name = 'Touring Rim' AND T3.Price = 0
5,406
sales
Find the number of customers handled by each of the sales people.
SELECT COUNT(CustomerID) FROM Sales GROUP BY SalesPersonID
5,407
sales
How many sales people are handling all the customers?
SELECT COUNT(EmployeeID) FROM Employees
5,408
sales
Identify the name of the sales person with employee ID 7.
name of the sales person = FirstName, MiddleInitial, LastName;
SELECT FirstName, MiddleInitial, LastName FROM Employees WHERE EmployeeID = 7
5,409
sales
Name the most expensive and the least expensive products available, excluding free gifts.
most expensive product refers to MAX(Price); least expensive product refers to MIN(Price); excluding free gifts refers to not including Price = 0;
SELECT Name FROM Products WHERE Price IN (( SELECT MAX(Price) FROM Products ), ( SELECT MIN(Price) FROM Products ))
5,410
sales
Among all the customers who have purchased ML Bottom Bracket, identify the percentage of sales by Albert I. Ringer?
ML Bottom Bracket' is name of product; percentage = MULTIPLY(DIVIDE(SUM(CustomerID WHERE FirstName = 'Albert' AND MiddleInitial = 'I' AND LastName = 'Ringer'), COUNT(CustomerID)), 1.0);
SELECT CAST(SUM(IIF(T3.FirstName = 'Albert' AND T3.MiddleInitial = 'I' AND T3.LastName = 'Ringer', 1, 0)) AS REAL) * 100 / COUNT(T2.CustomerID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T1.Name = 'ML Bottom Bracket'
5,411
sales
How many customers have the first name Abigail?
SELECT COUNT(CustomerID) FROM Customers WHERE FirstName = 'Abigail'
5,412
sales
Indicate the quantity of Blade products sold.
Blade' is name of product;
SELECT DISTINCT T2.Quantity FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Blade'
5,413
sales
Give the full name of the employee who has sold the most quantity.
full name of the employee = FirstName, LastName; most quantity refers to MAX(Quantity);
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID ORDER BY T2.Quantity DESC LIMIT 1
5,414
sales
List the full name of the customer who purchased the most quantity of products.
full name of the customer = FirstName, LastName; most quantity refers to MAX(Quantity);
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID ORDER BY T2.Quantity DESC LIMIT 1
5,415
sales
What is the name of the product that is most sold by sale person id 20?
most sold refers to MAX(Quantity);
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesPersonID = 20 ORDER BY T2.Quantity DESC LIMIT 1
5,416
sales
List the first names of employees with trading quantity for more than 500.
trading quantity for more than 500 refers to Quantity > 500;
SELECT DISTINCT T1.FirstName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T2.Quantity > 500
5,417
sales
List the first names of customers who have purchased products from sale person id 1.
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesPersonID = 1
5,418
sales
Calculate the total trading quantity of Abraham sold to Aaron Alexander.
total trading quantity = SUM(Quantity WHERE Employees.FirstName = 'Abraham' AND Customers.FirstName = 'Aaron' AND Customers.LastName = 'Alexander');
SELECT SUM(T2.Quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T2.SalesPersonID = 1 AND T1.FirstName = 'Aaron' AND T1.LastName = 'Alexander' AND T3.FirstName = 'Abraham'
5,419
sales
List the full names of customers who have purchased products in quantity over 600.
full names of customers = FirstName, LastName; quantity over 600 refers to quantity > 600;
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Quantity > 600
5,420
sales
Among the customers whose first name is Cameron, who bought the product in the most quantity?
most quantity refers to MAX(Quantity); who refers to FirstName, LastName;
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Cameron' ORDER BY T2.Quantity DESC LIMIT 1
5,421
sales
Please provide sales ID for products named Hex Nut with a price greater than 100.
price greater than 100 refers to price > 100;
SELECT T2.SalesID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Hex Nut%' AND T1.Price > 100
5,422
sales
Identify customer IDs who bought products priced from 1000 to 2000.
priced from 1000 to 2000 refers to Price BETWEEN 1000 AND 2000;
SELECT DISTINCT T2.CustomerID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price BETWEEN 1000 AND 2000
5,423
sales
Calculate the total quantity of products that are gifts.
total quantity = SUM(Quantity); gifts refers to Price = 0;
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price = 0
5,424
sales
Calculate the quantity percentage of the gift products in the total trading quantity.
percentage = MULTIPLY(DIVIDE(SUM(Quantity WHERE Price = 0), SUM(Quantity)), 1.0); gift products refers to Price = 0;
SELECT CAST(SUM(IIF(T1.Price = 0, T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity)FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
5,425
sales
Calculate the percentage of sold blades in the total number of transactions.
percentage = MULTIPLY(DIVIDE(SUM(Quantity WHERE Name = 'Blade'), SUM(Quantity)), 1.0); 'blades' refers to name of product;
SELECT CAST(SUM(IIF(T1.Name = 'Blade', T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
5,426
sales
How many of the employees have the last name "Ringer" ?
SELECT COUNT(LastName) FROM Employees WHERE LastName = 'Ringer'
5,427
sales
Among the products with product ID lower than 15, how many of them costs 10 and below?
product ID lower than 15 refers to ProductID < 15; costs 10 and below refers to Price; Price < = 10;
SELECT COUNT(ProductID) FROM Products WHERE ProductID < 15 AND Price <= 10
5,428
sales
Give the product's name brought by Aaron Alexander.
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Aaron' AND T3.LastName = 'Alexander'
5,429
sales
Give the product ID and name of the product with the highest prices among the quantity ranges from 400 to 500.
highest prices refers to MAX(Price); quantity ranges from 400 to 500 refers to Quantity BETWEEN 400 AND 500;
SELECT T1.ProductID, T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity BETWEEN 400 AND 500 ORDER BY T1.Price DESC LIMIT 1
5,430
sales
Among customers named Kate, who has the highest quantity?
highest quantity refers to MAX(Quantity);
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Kate' ORDER BY T1.Quantity DESC LIMIT 1
5,431
sales
Among the products that have price ranges from 100 to 150, what is the customer ID and sales ID of the product with a quantity lower than 25?
price ranges from 100 to 150 refers to Price BETWEEN 100 AND 150; quantity lower than 25 refers to Quantity < 25;
SELECT T2.CustomerID, T2.SalesID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price BETWEEN 100 AND 150 AND T2.Quantity < 25
5,432
sales
List the quantity and price of the product bought by Abigail Henderson.
SELECT T2.Quantity, T1.Price FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Abigail' AND T3.LastName = 'Henderson'
5,433
sales
In sales with a quantity of 60, how many of them have a price not greater than 500?
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity = 60 AND T1.Price <= 500
5,434
sales
In customers with the first name of Erica, how many of them bought a quantity below 200?
quantity below 200 refers to quantity < 200;
SELECT COUNT(T1.ProductID) FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Erica' AND T1.Quantity < 200
5,435
sales
Among products bought by Kathryn Ashe, what is the name of the product with the highest quantity?
highest quantity refers to MAX(Quantity);
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Kathryn' AND T3.LastName = 'Ashe' ORDER BY T2.Quantity DESC LIMIT 1
5,436
sales
What is the price and quantity of the product named Seat Tube?
SELECT DISTINCT T2.Price, T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Seat Tube'
5,437
sales
What is the price and name of the product bought by Erica Xu?
SELECT T3.Price, T3.Name FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID WHERE T2.FirstName = 'Erica' AND T2.LastName = 'Xu'
5,438
sales
List the sales ID of the product with a quantity of 590 and named "External Lock Washer 7".
External Lock Washer 7' is name of product;
SELECT T1.SalesID FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'External Lock Washer 7' AND T1.Quantity = 590
5,439
sales
In sales ID between 30 and 40, who is the customer that bought a total quantity of 403?
who refers to FirstName, LastName;
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity = 403 AND T1.SalesID BETWEEN 30 AND 40
5,440
sales
List the customer's ID and last name of the customer that purchased a product with a quantity greater than 90% of the average quantity of all listed products.
quantity greater than 90% of the average quantity = Quantity > MULTIPLY(AVG(Quantity), 0.9);
SELECT T2.CustomerID, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity > ( SELECT AVG(Quantity) FROM Sales ) * 0.9
5,441
sales
Among the sales ID ranges from 1 to 200, what is the percentage of the products with a price ranging from 200 to 300?
sales ID ranges from 1 to 200 refers to SalesID between 1 and 200; percentage = MULTIPLY(DIVIDE(SUM(Price between 200 and 300), COUNT(Price)), 1.0);
SELECT CAST(SUM(IIF(T2.Price BETWEEN 200 AND 300, 1, 0)) AS REAL) * 100 / COUNT(T2.Price) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SalesID BETWEEN 1 AND 200
5,442
sales
What is the name of the most expensive product?
most expensive product refers to MAX(Price);
SELECT Name FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products )
5,443
sales
How many customers are named Madison?
SELECT COUNT(CustomerID) FROM Customers WHERE FirstName = 'Madison'
5,444
sales
How many types of "HL Touring Frames" are there?
types of HL Touring Frames refers to Name like '%HL Touring Frame%';
SELECT COUNT(ProductID) FROM Products WHERE Name LIKE '%HL Touring Frame%'
5,445
sales
How many customers share the most common last name?
most common last name refers to MAX(COUNT(LastName));
SELECT COUNT(CustomerID) FROM Customers GROUP BY LastName ORDER BY COUNT(LastName) DESC LIMIT 1
5,446
sales
How many free or gift products are there?
free gift refers to Price = 0;
SELECT COUNT(ProductID) FROM Products WHERE Price = 0
5,447
sales
What is the name of the sales person who handled the highest number of sales?
name of the sales person = FirstName, MiddleInitial, LastName; highest number of sales refers to MAX(COUNT(SalesID));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T2.SalesPersonID = T1.EmployeeID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 1
5,448
sales
What is the full name of the customer who purchased the highest amount of total price in a single purchase?
full name of the customer = FirstName, MiddleInitial, LastName; highest amount of total price refers to MAX(MULTIPLY(Quantity, Price));
SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID GROUP BY T1.SalesID, T1.Quantity, T3.Price, FirstName, MiddleInitial, LastName ORDER BY T1.Quantity * T3.Price DESC LIMIT 1
5,449
sales
How many "Mountain-500 Black 42" were sold in total?
Mountain-500 Black 42' is name of product; sold in total = SUM(Quantity);
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain-500 Black, 42'
5,450
sales
How much is the total amount of sales handled by Heather McBadden?
total amount of sales = SUM(MULTIPLY(Quantity, Price));
SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Heather' AND T1.LastName = 'McBadden'
5,451
sales
How many "Mountain-100 Silver, 38" were sold by Stearns MacFeather?
Mountain-100 Silver, 38' is name of product;
SELECT SUM(T2.Quantity) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Stearns' AND T1.LastName = 'MacFeather' AND T3.Name = 'Mountain-100 Silver, 38'
5,452
sales
How many type of products did Dalton M. Coleman purchase?
SELECT COUNT(T2.ProductID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Dalton' AND T1.MiddleInitial = 'M' AND T1.LastName = 'Coleman'
5,453
sales
What are the full names of the top 3 employees who handled the highest number of sales?
full names of employees = FirstName, MiddleInitital, LastName; highest number of sales refers to MAX(COUNT(SalesID));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 3
5,454
sales
Among the "Mountain-500 Black" product types, which type was purchased the most?
Mountain-500 Black product types refers to Name like 'Mountain-500 Black%'; purchased the most refers to MAX(SUM(Quantity));
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Mountain-500 Black%' GROUP BY T2.Quantity, T1.Name ORDER BY SUM(T2.Quantity) DESC LIMIT 1
5,455
sales
How many employees sold "ML Road Frame-W - Yellow, 40"?
ML Road Frame-W - Yellow, 40' is name of product;
SELECT COUNT(T2.SalesPersonID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'ML Road Frame-W - Yellow, 40'
5,456
sales
How many chainring bolts were sold under sales ID 551971?
Chainring Bolts' is name of product;
SELECT T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Chainring Bolts' AND T1.SalesID = 551971
5,457
sales
How many employees sold over 20,000 quantities of "Touring-2000 Blue, 50"?
over 20,000 quantities refers to Quantity > 20000; 'Touring-2000 Blue, 50' is name of product;
SELECT COUNT(*) FROM ( SELECT SUM(Quantity) FROM Sales WHERE ProductID IN ( SELECT ProductID FROM Products WHERE Name = 'Touring-2000 Blue, 50' ) GROUP BY Quantity, SalesPersonID HAVING SUM(Quantity) > 20000 )
5,458
sales
What is the total cost of all the "Road-650, Red, 60" products that Abraham E. Bennet sold?
total cost = SUM(MULTIPLY(Quantity, Price)); 'Road-650, Red, 60' is name of product;
SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Abraham' AND T1.MiddleInitial = 'e' AND T1.LastName = 'Bennet' AND T3.Name = 'Road-650 Red, 60'
5,459
sales
Which product has the highest total amount of quantity sold? Calculate its overall total price.
highest total amount of quantity refers to MAX(Quantity); overall total price = SUM(MULTIPLY(Quantity, Price));
SELECT T1.Name, SUM(T2.Quantity * T1.Price) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T1.Name ORDER BY SUM(T2.Quantity) DESC LIMIT 1
5,460
sales
List the first name of all the customers whose last name is Chen.
SELECT FirstName, LastName FROM Customers WHERE LastName = 'Chen'
5,461
sales
Among the employee names, what is the most common middle initial?
most common middle initial refers to MAX(COUNT(MiddleInitial));
SELECT MiddleInitial FROM Employees GROUP BY MiddleInitial ORDER BY COUNT(MiddleInitial) DESC LIMIT 1
5,462
sales
What is the average price of products that cost between 100 and 200?
average price = DIVIDE(SUM(Price, COUNT(Price))); cost refers to Price; Price BETWEEN 100 AND 200;
SELECT AVG(Price) FROM Products WHERE Price BETWEEN 100 AND 200
5,463
sales
Find and list the full name of customers who bought products above-average quantity.
full name of the customer = FirstName, MiddleInitial, LastName; above-average quantity = Quantity > AVG(Quantity);
SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.Quantity HAVING T1.Quantity > ( SELECT AVG(Quantity) FROM Sales )
5,464
sales
Give the full name of the customer who bought the most amount of products.
full name of the customer = FirstName, MiddleInitial, LastName; most amount of products refers to MAX(MULTIPLY(Quantity, Price));
SELECT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID ORDER BY T2.Quantity * T1.Price DESC LIMIT 1
5,465
sales
Of the employees who sold Blade, who has the most amount of sales?
Blade' is name of product; most amount of sales refers to MAX(MULTIPLY(Quantity, Price));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID ORDER BY T2.Quantity * T3.Price DESC LIMIT 1
5,466
sales
List the full name of customers who spend more than 50,000 in descending order the amount spend.
full name of the customer = FirstName, MiddleInitial, LastName; more than 50,000 in the amount refers to MULTIPLY(Quantity, Price) > 50000;
SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T2.Quantity * T1.Price > 50000
5,467
sales
Name the product that sold the most quantity.
most quantity refers to MAX(Quantity);
SELECT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.Quantity DESC LIMIT 1
5,468
sales
Find and list the products that sold below the average quantity.
below the average quantity refers to Quantity < AVG(Quantity);
SELECT DISTINCT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity < ( SELECT AVG(Quantity) FROM Sales )
5,469
menu
How many dishes do not have correct data for the year in which it appeared first?
do not have correct data refers to first_appeared < 1851 or first_appeared > 2012;
SELECT COUNT(*) FROM Dish WHERE first_appeared < 1851 OR first_appeared > 2012
5,470
menu
Which dish lasted longer, Anchovies or Fresh lobsters in every style?
if (SUBTRACT(last_appeared, first_appeared) WHERE name = 'Anchovies') > (SUBTRACT(last_appeared, first_appeared) WHERE name = 'Fresh lobsters in every style'), it means 'Anchovies' lasted longer; if (SUBTRACT(last_appeared , first_appeared) WHERE name = 'Fresh lobsters in every style') > (SUBTRACT(last_appeared , first_appeared) WHERE name = 'Anchovies') it means 'Fresh lobsters in every style' last longer;
SELECT CASE WHEN SUM(CASE WHEN name = 'Anchovies' THEN last_appeared - first_appeared ELSE 0 END) - SUM(CASE WHEN name = 'Fresh lobsters in every style' THEN last_appeared - first_appeared ELSE 0 END) > 0 THEN 'Anchovies' ELSE 'Fresh lobsters in every style' END FROM Dish WHERE name IN ('Fresh lobsters in every style', 'Anchovies')
5,471
menu
Among all the dishes that were once free, what is the name of the dish that had appeared on most menus?
dishes that were once free refers to lowest_price = 0; appeared on most menus refers to MAX(menus_appeared);
SELECT name FROM Dish WHERE lowest_price = 0 ORDER BY menus_appeared DESC LIMIT 1
5,472
menu
How many menus with the name "Waldorf Astoria" have 4 pages?
4 pages refers to page_count = 4;
SELECT COUNT(*) FROM Menu WHERE name = 'Waldorf Astoria' AND page_count = 4
5,473
menu
What is the name of the dish that appeared on the upper left corner on menu page no. 1389?
appeared on the upper left corner on menu refers to xpos < 0.25 AND ypos < 0.25; menu page no. refers to menu_page_id; menu_page_id = 1389;
SELECT T1.name FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T2.menu_page_id = 1389 AND T2.xpos < 0.25 AND T2.ypos < 0.25
5,474
menu
Please list the prices of the dish "Clear green turtle" on every menu page it appeared on.
Clear green turtle is a name of dish;
SELECT T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.name = 'Clear green turtle'
5,475
menu
Among all the menu pages with the appearance of the dish "Clear green turtle", how many of them have the dish at a stable price?
Clear green turtle is a name of dish; stable price refers to highest_price is null;
SELECT SUM(CASE WHEN T1.name = 'Clear green turtle' THEN 1 ELSE 0 END) FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.highest_price IS NULL
5,476
menu
What is the highest price of the dish "Clear green turtle" on a menu page?
highest price refers to MAX(Price); Clear green turtle is a name of dish;
SELECT T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.name = 'Clear green turtle' ORDER BY T2.price DESC LIMIT 1
5,477
menu
Please list the IDs of all the menus in which the dish "Clear green turtle" had appeared.
Clear green turtle is a name of dish;
SELECT T1.menu_id FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id INNER JOIN Dish AS T3 ON T2.dish_id = T3.id WHERE T3.name = 'Clear green turtle'
5,478
menu
Among the menus in which the dish "Clear green turtle" had appeared, how many of them used the dollar as their currency?
Clear green turtle is a name of dish; dollar as currency refers to currency = 'Dollars';
SELECT SUM(CASE WHEN T3.currency = 'Dollars' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Clear green turtle'
5,479
menu
Among the menus in which the dish "Clear green turtle" had appeared, how many of them did not support taking out or booking in advance?
Clear green turtle is a name of dish; not support taking out or booking in advance refers to call_number is null;
SELECT SUM(CASE WHEN T4.name = 'Clear green turtle' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.call_number IS NULL
5,480
menu
Please list the names of all the dishes that appeared on the menu "Zentral Theater Terrace".
Zentral Theater Terrace is a name of menu;
SELECT T4.name FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.name = 'Zentral Theater Terrace'
5,481
menu
Which dish has the highest price on the menu "Zentral Theater Terrace"? Please give its name.
highest price refers to MAX(Price); Zentral Theater Terrace is a name of menu;
SELECT T4.name FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.name = 'Zentral Theater Terrace' ORDER BY T1.price DESC LIMIT 1
5,482
menu
How many dishes are there on the menu "Zentral Theater Terrace"?
Zentral Theater Terrace is a name of menu;
SELECT SUM(CASE WHEN T3.name = 'Zentral Theater Terrace' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id
5,483
menu
How many dishes are there in total in the menus with the name "Waldorf Astoria"?
FALSE;
SELECT SUM(CASE WHEN T3.name = 'Waldorf Astoria' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id
5,484
menu
Please list the IDs of the menus that are DIYs of the restaurant and have the dish "Clear green turtle".
IDs of the menus refers to menu_id; menus that are DIYs of the restaurant refers to sponsor is null; Clear green turtle is a name of dish;
SELECT T2.menu_id FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Clear green turtle' AND T3.sponsor IS NULL
5,485
menu
What is the average page number of the menus that have the dish "Clear green turtle"?
average page number = AVG(page_number); Clear green turtle is a name of dish;
SELECT AVG(T1.page_number) FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id INNER JOIN Dish AS T3 ON T2.dish_id = T3.id WHERE T3.name = 'Clear green turtle'
5,486
menu
What is the average price of the dishes on the menu "Zentral Theater Terrace"?
average price = AVG(price); Zentral Theater Terrace refers to menu;
SELECT SUM(T1.price) / COUNT(T1.price) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id WHERE T3.name = 'Zentral Theater Terrace'
5,487
menu
How many menu items were created on 28th March 2011?
created on 28th March 2011 refers to created_at like '2011-03-28%';
SELECT COUNT(*) FROM MenuItem WHERE created_at LIKE '2011-03-28%'
5,488
menu
How many dishes are included in the menu page ID 144?
FALSE;
SELECT COUNT(*) FROM MenuItem WHERE menu_page_id = 144
5,489
menu
How many menus were used in Dutcher House?
Dutcher House refers to location = 'Dutcher House';
SELECT COUNT(*) FROM Menu WHERE location = 'Dutcher House'
5,490
menu
How many dishes appeared on a menu more than once?
appeared on a menu more than once refers to times_appeared > menus_appeared;
SELECT COUNT(*) FROM Dish WHERE times_appeared > menus_appeared
5,491
menu
How many menus were created for steamship?
steamship refers to venue = 'STEAMSHIP';
SELECT COUNT(*) FROM Menu WHERE venue = 'STEAMSHIP'
5,492
menu
How many pages were there on the menu created on 17th November 1898?
created on 17th November 1898 refers to date = '1898-11-17';
SELECT SUM(CASE WHEN T1.date = '1898-11-17' THEN 1 ELSE 0 END) FROM Menu AS T1 INNER JOIN MenuPage AS T2 ON T1.id = T2.menu_id
5,493
menu
Name the dishes that were on the menu page ID 174.
FALSE;
SELECT T2.name FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE T1.menu_page_id = 174
5,494
menu
List the names and menu page IDs of the dishes that first appeared in 1861.
first appeared in 1861 refers to first_appeared = 1861;
SELECT T2.name, T1.dish_id FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE T2.first_appeared = 1861
5,495
menu
Among the dishes on menu page ID 7610, list the names and highest prices of the dishes in menu items that were created on 23rd May 2011.
highest prices of the dishes refers to MAX(price); created on 23rd May 2011 refers to created_at like '2011-05-23%';
SELECT T1.name, T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T2.created_at LIKE '2011-05-23%' ORDER BY T2.price DESC LIMIT 1
5,496
menu
List the dishes included on page number 30 with the least in full height.
least in full height refers to MIN(full_height);
SELECT T3.name FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id INNER JOIN Dish AS T3 ON T2.dish_id = T3.id WHERE T1.page_number = 30 ORDER BY T1.full_height DESC, T1.full_height ASC LIMIT 1
5,497
menu
Provide the page IDs and name of the menu which had the highest page count.
page IDs refers to page_number; highest page count refers to MAX(page_count);
SELECT T1.page_number, T2.name FROM MenuPage AS T1 INNER JOIN Menu AS T2 ON T2.id = T1.menu_id ORDER BY T2.page_count DESC LIMIT 1
5,498
menu
On the menu with the most dishes, how many dishes were there on its second page?
menu with the most dishes refers to menu.id with MAX(dish_count); second page refers to page_number = 2;
SELECT COUNT(T1.dish_id) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id WHERE T2.page_number = 2 GROUP BY T3.name ORDER BY T3.dish_count DESC LIMIT 1
5,499