db_id stringclasses 69 values | question stringlengths 24 325 | evidence stringlengths 0 673 | SQL stringlengths 23 804 |
|---|---|---|---|
retail_world | Please indicate the product name of Tokyo Traders company with order quantity greater than 40. | 'Tokyo Traders' is a CompanyName; order quantity greater than 40 refers to Quantity > 40 | SELECT DISTINCT T2.ProductName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID WHERE T1.CompanyName = 'Tokyo Traders' AND T3.Quantity > 40 |
retail_world | List all category name of Exotic Liquids 's product with units in stock over 100. | 'Exotic Liquids' is a CompanyName; units in stock over 100 refers to UnitsInStock > 100 | SELECT T3.CategoryName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T2.UnitsInStock > 100 AND T1.CompanyName = 'Exotic Liquids' |
retail_world | How many product names have order quantity less than 50? Calculate the percentage of orders less than 50 out of total order quantity. | order quantity less than 50 refers to Quantity < 50; Calculation = DIVIDE(SUM(Quantity < 50), SUM(ProductID)) * 100 | SELECT SUM(CASE WHEN T2.Quantity < 50 THEN 1 ELSE 0 END) , CAST(SUM(IF(T2.Quantity < 50, 1, 0)) AS REAL) / COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID |
retail_world | Please indicate total order quantity of product Geitost and calculate the percentage of such product among all the order quantity. | 'Geitost' is a ProductName; calculation = DIVIDE(ProductName = 'Geitost', COUNT(ProductID)) * 100 | SELECT SUM(IF(T1.ProductName = 'Geitost', 1, 0)) AS sum , CAST(SUM(IF(T1.ProductName = 'Geitost', 1, 0)) AS REAL) / COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID |
retail_world | What is the position of Robert King? | 'Robert King' is the full name of an employee; full name refers to FirstName, LastName; position refers to Title | SELECT Title FROM Employees WHERE FirstName = 'Robert' AND LastName = 'King' |
retail_world | Write the shipping company name with the telephone number of (503) 555-9931. | telephone number of (503) 555-9931 refers to Phone = '(503) 555-9931' | SELECT CompanyName FROM Shippers WHERE Phone = '(503) 555-9931' |
retail_world | Write the address and phone number of Margaret Peacock. | Margaret Peacock is the full name of an employee; full name refers to FirstName, LastName; phone number refers to HomePhone | SELECT Address, HomePhone FROM Employees WHERE FirstName = 'Margaret' AND LastName = 'Peacock' |
retail_world | What is the full address of Rattlesnake Canyon Grocery? | full address refers to ShipAddress, ShipCity, ShipRegion,ShipPostalCode, ShipCountry; 'Rattlesnake Canyon Grocery' is a ShipName; | SELECT DISTINCT ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry FROM Orders WHERE ShipName = 'Rattlesnake Canyon Grocery' |
retail_world | List all product names under Confections. | 'Confections' is a CompanyName; | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Confections' |
retail_world | Sir Rodney's Marmalade is supplied by which company and who is the contact for this company? | 'Sir Rodney's Marmalade' is a ProductName; company refers to CompanyName; contact for a company refers to ContactName | SELECT T2.CompanyName, T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName LIKE 'Sir Rodney%s Marmalade' |
retail_world | What is the full name of the employee who is in charge of the territory of Denver? | full name refers to FirstName, LastName; Denver is a TerritoryDescription | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Denver' |
retail_world | List all the territories where Laura Callahan is in charge. | territories refers to TerritoryDescription; Laura Callahan is the full name of an employee; full name refers to FirstName, LastName | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.FirstName = 'Laura' AND T1.LastName = 'Callahan' |
retail_world | How many orders were shipped via Federal Shipping? | 'Federal Shipping' is a CompanyName; orders refers to OrderID | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShipVia = 3 |
retail_world | Name the products where the suppliers come from Finland. | 'Finland' is a Country; product refers to ProductName; suppliers refers to SupplierID | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Finland' |
retail_world | The product 'Mozzarella di Giovanni' belongs in which category? Include the category's description as well. | Mozzarella di Giovanni' is a ProductName; category refers to CategoryName; | SELECT T2.CategoryName, T2.Description FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.ProductName = 'Mozzarella di Giovanni' |
retail_world | Name the suppliers that supply products under the category 'cheeses.' | suppliers refers to CompanyName; 'cheeses' is a Description | SELECT DISTINCT T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T3.Description = 'Cheeses' |
retail_world | Name all products supplied by Zaanse Snoepfabriek. | products refers to ProductName; 'Zaanse Snoepfabriek' is a CompanyName | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Zaanse Snoepfabriek' |
retail_world | Which products by Plutzer Lebensmittelgromrkte AG were discontinued and what are their price? | products refers to ProductName; 'Plutzer Lebensmittelgromrkte AG' is a CompanyName; price refers to UnitPrice;
discontinued products refers to discontinued = 1 | SELECT T1.UnitPrice FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Plutzer Lebensmittelgromrkte AG' AND T1.Discontinued = 1 |
retail_world | List the cities where the product 'Mishi Kobe Niku' were shipped to. | cities refers to ShipCity; 'Mishi Kobe Niku' is a ProductName | SELECT T1.ShipCity FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T3.ProductName = 'Mishi Kobe Niku' |
retail_world | What percentage does the shipment of products by Speedy Express to Sweden make up to the shipping company's total? | Speedy Express is a company; Sweden is a ShipCountry; calculation = DIVIDE(SUM(ShipCountry = 'Sweden'), SEM(ShipCountry)) * 100 | SELECT CAST(COUNT(CASE WHEN T1.ShipCountry = 'Sweden' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Speedy Express' |
retail_world | How many territory fall into region 1? | region 1 refers to RegionID = 1
| SELECT COUNT(TerritoryID) FROM Territories WHERE RegionID = 1 |
retail_world | What are the the total number of territory in each region? | SELECT COUNT(TerritoryDescription) FROM Territories WHERE RegionID IN (1, 2, 3, 4) GROUP BY RegionID | |
retail_world | How many suppliers are from UK? | from UK refers to Country = 'UK' | SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'UK' |
retail_world | Please give the contact name for Tokyo Traders. | Tokyo Traders refers to CompanyName = 'Tokyo Traders' | SELECT ContactName FROM Suppliers WHERE CompanyName = 'Tokyo Traders' |
retail_world | How many employees from USA with Sales Representative title? | from USA refers to Country = 'USA' | SELECT COUNT(Country) FROM Employees WHERE Country = 'USA' AND Title = 'Sales Representative' |
retail_world | What are the highest salary earn by the the employee and what is his/her position in the company? | highest salary refers to max(salary); position refers to Title | SELECT Salary, Title FROM Employees WHERE Salary = ( SELECT MAX(Salary) FROM Employees ) |
retail_world | How many products supplied by Plutzer Lebensmittelgromrkte AG that is currently out of stock and on order? | Plutzer Lebensmittelgromrkte AG refers to CompanyName; is currently out of stock and on order refers to UnitsInStock = 0 and UnitsOnOrder > 0 | SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Plutzer Lebensmittelgromrkte AG' AND T1.UnitsInStock = 0 AND T1.UnitsOnOrder = 0 |
retail_world | What product have the highest unit price and how many quantity have been being sold? | product refers to ProductID; highest unit price refers to Max(UnitPrice) | SELECT T1.ProductName, T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.UnitPrice DESC LIMIT 1 |
retail_world | Which employee has created the least order and please indicates the employee's title? | least order refers to Min(OrderID) | SELECT T1.Title FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.Title ORDER BY COUNT(T2.OrderID) LIMIT 1 |
retail_world | What is the most common product ordered by a customer from Germany? | most common product refers to max(count(ProductID)); customer from Germany refers to Country = 'Germany' | SELECT T2.ProductID FROM Customers AS T1 INNER JOIN `Order Details` AS T2 WHERE T1.Country = 'Germany' GROUP BY T2.ProductID ORDER BY COUNT(T2.ProductID) DESC LIMIT 1 |
retail_world | What are the total products value shipped to Brazil by Speedy Express Company? | shipped to Brazil refers to ShipCountry = 'Brazil'; by Speedy Express Company refers to CompanyName = 'Speedy Express'; total products value refers to sum(MULTIPLY(UnitPrice, Quantity)) | SELECT SUM(T2.Quantity * T2.UnitPrice) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Shippers AS T3 ON T1.ShipVia = T3.ShipperID WHERE T3.CompanyName = 'Speedy Express' AND T1.ShipCountry = 'Brazil' |
retail_world | How many subordinates does employee ID 2 have and what is the biggest order in terms of value that his/her subordinates have created? | subordinates of employee ID 2 refers to EmployeeID where ReportsTo = 2; biggest order in terms of value refers to max(MULTIPLY(Quantity, UnitPrice)) | SELECT COUNT(T1.EmployeeID), SUM(T3.Quantity * T3.UnitPrice) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID WHERE T1.ReportsTo = 2 ORDER BY SUM(T3.UnitPrice * T3.Quantity) DESC LIMIT 1 |
retail_world | How many sales values have been created by sales representative and which sales representative have the highest sales? | sales representative refers to Title = 'Sales Representative'; sales values refers to MULTIPLY(Quantity, UnitPrice); the highest sales refers to max(MULTIPLY(Quantity, UnitPrice)) | SELECT SUM(T3.UnitPrice * T3.Quantity) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID WHERE T1.Title = 'Sales Representative' ORDER BY SUM(T3.UnitPrice * T3.Quantity) |
retail_world | How many employees is a UK citizen and are they all covering the same region? | is a UK citizen refers to Country = 'UK' | SELECT COUNT(T1.EmployeeID), T3.RegionID FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.Country = 'UK' GROUP BY T3.RegionID |
retail_world | Which customer have the biggest purchase in one order and where does this order being ship to? | biggest purchase refers to max(ProductID.Order_Details); ship to refers to ShipCountry | SELECT T1.CompanyName, T2.ShipCountry FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID GROUP BY T1.CompanyName, T2.ShipCountry ORDER BY COUNT(T3.ProductID) DESC LIMIT 1 |
retail_world | Which customer is a regular customer in this shop and what are the products category that he mostly buy? | regular customer refers to max(count(CustomerID)); products category refers to CategoryName; mostly buy refers to max(count(CategoryID)) | SELECT T1.CustomerID, T4.CategoryName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID INNER JOIN Categories AS T4 ON T3.CategoryID = T4.CategoryID ORDER BY T1.CustomerID DESC, T4.CategoryName DESC |
retail_world | What are the most popular confections product and calculate the total sales generated by this product? | most popular confections product refers to ProductID = max(count(MULTIPLY(Quantity, UnitPrice))) from CategoryName = 'Confections' ; total sales refers to sum(MULTIPLY(Quantity, UnitPrice)) | SELECT COUNT(T1.UnitPrice * T3.Quantity) FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID INNER JOIN `Order Details` AS T3 ON T1.ProductID = T3.ProductID WHERE T2.CategoryName = 'Confections' GROUP BY T3.Quantity ORDER BY T3.Quantity DESC LIMIT 1 |
retail_world | What is the name of product with the ID of 77? | name of product refers to ProductName; ID refers to ProductID | SELECT ProductName FROM Products WHERE ProductID = 77 |
retail_world | State the company name of all suppliers in USA. | in USA refers to Country = 'USA' | SELECT CompanyName FROM Suppliers WHERE Country = 'USA' |
retail_world | What is the position title for Laura Callahan? | SELECT Title FROM Employees WHERE FirstName = 'Laura' AND LastName = 'Callahan' | |
retail_world | State the name of employee that manages the order from Victuailles en stock? | name of employee refers to FirstName; from Victuailles en stock refers to CompanyName = 'Victuailles en stock' | SELECT DISTINCT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.CompanyName = 'Victuailles en stock' |
retail_world | How many orders were shipped by Federal Shipping? | Federal Shipping refers to CompanyName = 'Federal Shipping' | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' |
retail_world | Who was taking charge of orders from Morristown? | Morristown refers to TerritoryDescription = 'Morristown' | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Morristown' |
retail_world | State the name of all territories in Northern region. | name of all territories refers to TerritoryDescription; Northern region refers to RegionDescription = 'Northern' | SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Northern' |
retail_world | How many orders were handled by Michael Suyama. State the order ID. | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama' | |
retail_world | What is the ratio number of territories in Northern region and number territories in Western region? | Northern region refers to RegionID = 3; Western region refers to RegionID = 2 ; ratio = divide((TerritoryDescription where RegionID = 3), (TerritoryDescription where RegionID = 2)) | SELECT CAST(( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Northern' ) AS REAL) * 100 / ( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Westerns' ) AS Calu |
retail_world | Provide employees' ID who are in-charge of territory ID from 1000 to 2000. | territory ID from 1000 to 2000 refers to TerritoryID BETWEEN 1000 and 2000 | SELECT EmployeeID FROM EmployeeTerritories WHERE TerritoryID BETWEEN 1000 AND 2000 |
retail_world | List down the territory IDs, descriptions and region description which are under the in-charge of Nancy Davolio, | descriptions refers to TerritoryDescription; region refers to RegionDescription | SELECT T3.RegionID, T3.TerritoryDescription, T4.RegionDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID INNER JOIN Region AS T4 ON T3.RegionID = T4.RegionID WHERE T1.LastName = 'Davolio' AND T1.FirstName = 'Nancy' |
retail_world | Describe Sales Representative names who were hired in 1992 and compare the number of orders among them. | Sales Representative refers to Title = 'Sales Representative';were hired in 1992 refers to HireDate = '1992' | SELECT T1.FirstName, T1.LastName, COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.Title = 'Sales Representative' AND STRFTIME('%Y', T1.HireDate) = '1992' GROUP BY T1.EmployeeID, T1.FirstName, T1.LastName |
retail_world | Calculate the total payment of orders for Vegie-spread product. | Vegie-spread product refers to ProductName = 'Vegie-spread';total payment = MULTIPLY(UnitPrice, Quantity, (1-Discount)) | SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) AS sum FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Vegie-spread' |
retail_world | List down the company names which supplied products for the order on 14th August, 1996. | products refers to Order_Details.ProductID; on 14th August, 1996 refers to OrderDate = '8/14/1996' | SELECT T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID INNER JOIN Orders AS T4 ON T3.OrderID = T4.OrderID WHERE date(T4.OrderDate) = '1996-08-14' |
retail_world | Among the product lists in order ID 10337, write down the product names and suppliers which had the highest in reorder level. | suppliers refers to CompanyName; highest in reorder level refers to Max(ReorderLevel) | SELECT T2.ProductName, T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID WHERE T3.OrderID = 10337 ORDER BY T2.ReorderLevel DESC LIMIT 1 |
retail_world | Name the shipper which had the most shipments in first quarter of 1998. | Name the shipper refers to CompanyName; most shipments refers to max(count(OrderID)); first quarter of 1998 refers to ShippedDate = 1998/1 and ShippedDate = 1998/2 and ShippedDate = 1998/3 and ShippedDate = 1998/4 | SELECT T1.CompanyName FROM Shippers AS T1 INNER JOIN Orders AS T2 ON T1.ShipperID = T2.ShipVia WHERE STRFTIME('%Y', T2.ShippedDate) = '1998' GROUP BY T1.CompanyName ORDER BY COUNT(T2.OrderID) DESC LIMIT 1 |
retail_world | How many customers are located in London? | London refers to City = 'London' | SELECT COUNT(CustomerID) FROM Customers WHERE City = 'London' |
retail_world | What is the title of Michael Suyama? | SELECT Title FROM Employees WHERE FirstName = 'Michael' AND LastName = 'Suyama' | |
retail_world | List out the full name of employee who has birth day on "3/4/1955 12:00:00 AM". | full name refers to FirstName, LastName; brith day refers to BirthDate | SELECT FirstName, LastName FROM Employees WHERE BirthDate = '1955-03-04 00:00:00' |
retail_world | Mention the first name of employee who took care the order id 10250. | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10250 | |
retail_world | How many orders that the employees who are located in Tacoma handled? | located in Tacoma refers to City = 'Tacoma' | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.City = 'Tacoma' |
retail_world | What is the country location of the employee who handled order id 10257? | SELECT T1.Country FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10257 | |
retail_world | What is the title of the employee who handled order id 10270? | SELECT T1.Title FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10257 | |
retail_world | Give the phone number of the customer who placed the order id 10264. | SELECT T1.Phone FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10264 | |
retail_world | What is the region where the customer who placed the order id 10276 located? | SELECT T1.Region FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10276 | |
retail_world | Among the employees who handled orders to Brazil, who has the highest salary and calculate the average salary of them. | orders to Brazil refers to ShipCountry = 'Brazil'; highest salary refers to max(salary); average salary = AVG(Salary) | SELECT T1.FirstName, T1.LastName, AVG(T1.Salary) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.ShipCountry = 'Brazil' GROUP BY T1.FirstName, T1.LastName ORDER BY SUM(T1.Salary) DESC LIMIT 1 |
retail_world | Calculate the percentage salary of employees who handled orders shipped in 1996. | shipped in 1996 refers to ShippedDate = 1996; percentage salary = divide(sum(Salary when ShippedDate = 1996), sum(Salary)) as percentage | SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T2.ShippedDate) = '1996' THEN T1.Salary ELSE 0 END) AS REAL) * 100 / SUM(T1.Salary) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID |
retail_world | When was the employee who handled order id 10281 hired? | When was hired refers to HireDate | SELECT T1.HireDate FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10281 |
retail_world | How many orders was handled by employees who reported to employee id 5? | reported to employee id 5 refers to ReportsTo = 5 | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.ReportsTo = 5 |
retail_world | Give the full name of employee who handled the order id 10280. | full name refers to FirstName, LastName | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10280 |
retail_world | State the shipping company of order id 10260. | shipping company refers to CompanyName | SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10260 |
retail_world | How many orders have been shipped through United Package? | shipped through refers to ShipVia; United Package refers to CompanyName = 'United Package' | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'United Package' |
retail_world | List out the phone number of the shipping company of order id 10296. | shipping company refers to Shippers; phone number refers to Phone | SELECT T2.Phone FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10260 |
retails | How many kinds of items are returned in order no.5? | returned refer to l_returnflag = 'R'; order no.5 refers to l_orderkey = 5; kinds of items refer to l_linenumber; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_orderkey = 5 AND l_returnflag = 'R' |
retails | When was the latest date the items of order no.1 were shipped? | order no.1 refers to l_orderkey = 1; the latest date shipped refers to MAX(l_shipdate); | SELECT MAX(l_shipdate) FROM lineitem WHERE l_orderkey = 1 |
retails | Which order has a higher priority, order no. 4 or order no. 36? | earlier orderdate have higher priority in delivery; which order no. 4 or order no. 36 refers to o_orderkey in (4, 36) where MIN(o_orderdate); | SELECT l_orderkey FROM lineitem WHERE l_orderkey IN (4, 36) ORDER BY l_shipdate DESC LIMIT 1 |
retails | What is the comment of the order with the highest total price? | the highest total price refers to MAX(o_totalprice); comment of the order refers to o_comment; | SELECT o_comment FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders ) |
retails | What is the phone number of Customer#000000001? | customer phone refers to c_phone; Customer#000000001 refers to c_name; | SELECT c_phone FROM customer WHERE c_name = 'Customer#000000001' |
retails | How many orders in total have the customers in the household segment made? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; | SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Among all the orders made by a customer in the household segment, what is the highest total price? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the highest total price refers to MAX(o_totalprice); | SELECT MAX(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Please list the order comments of all the orders made by customers in the household segment. | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; order comments refer to o_comment; | SELECT T1.o_comment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
retails | Please give the name of the customer who has made the single order with the highest total price. | name of the customer refers to c_name; single order with the highest total price refers to MAX(o_totalprice) LIMIT 1; | SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey ORDER BY T1.o_totalprice DESC LIMIT 1 |
retails | Please list the order keys of all the orders made by a customer whose account is in debt. | account is in debt if c_acctbal < 0; | SELECT T1.o_orderkey FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_acctbal < 0 |
retails | Among the orders made by customers in the household segment, how many of them are urgent? | orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the order is urgent if o_orderpriority = '1-URGENT' ; | SELECT COUNT(T1.o_orderpriority) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' AND T1.o_orderpriority = '1-URGENT' |
retails | How many customers are in Brazil? | Brazil is the name of the nation which refers to n_name = 'BRAZIL' | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'BRAZIL' |
retails | Please list the phone numbers of all the customers in the household segment and are in Brazil. | phone numbers refer to c_phone; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; household segment refers to c_mktsegment = 'HOUSEHOLD'; | SELECT T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'BRAZIL' |
retails | Among all the customers in Germany, how many of them have an account balance of over 1000? | Germany is the name of the nation which refers to n_name = 'GERMANY'; account balance of over 1000 refers to c_acctbal > 1000; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'GERMANY' AND T1.c_acctbal > 1000 |
retails | How many orders in total are made by customers in Germany? | orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; | SELECT COUNT(T2.c_custkey) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | What is the total price of all the orders made by customers in Germany? | orders refer to o_orderkey; total price refers to o_totalprice; Germany is the name of the nation which refers to n_name = 'GERMANY'; | SELECT SUM(T3.o_totalprice) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | Among the orders made by customers in Germany, which one of them has the highest priority in delivery? Please give its order key. | orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; earlier orderdate have higher priority in delivery therefore MIN(o_orderdate); | SELECT T3.o_orderkey FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' ORDER BY T3.o_orderdate LIMIT 1 |
retails | What is the average price of the orders made by a customer in Germany? | DIVIDE(SUM(o_totalprice), COUNT(o_orderkey)) where n_name = 'GERMANY'; | SELECT AVG(T3.o_totalprice) FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN orders AS T3 ON T2.c_custkey = T3.o_custkey WHERE T1.n_name = 'GERMANY' |
retails | Among all the customers, what is the percentage of the customer's nation being Germany? | DIVIDE(COUNT(c_custkey when n_name = 'GERMANY'), COUNT(c_custkey)) as percentage; | SELECT CAST(SUM(IIF(T2.n_name = 'GERMANY', 1, 0)) AS REAL) * 100 / COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey |
retails | How many countries are there in the No.2 region? | No.2 region refers to n_regionkey = 2; | SELECT COUNT(n_nationkey) FROM nation WHERE n_regionkey = 2 |
retails | Which country does supplier No.34 come from? | supplier No.34 refers to s_suppkey = 34; country refers to n_name; | SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_suppkey = 34 |
retails | Which region does "Supplier#000000129" belong to? | "Supplier#000000129" is the name of the supplier which refers to s_name; Which region refers to r_name; | SELECT T3.r_name FROM nation AS T1 INNER JOIN supplier AS T2 ON T1.n_nationkey = T2.s_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.s_name = 'Supplier#000000129' |
retails | What is the nationality of "Customer#000000055"? | "Customer#000000055" is the name of the customer which refers to c_name; nationality is the state of belonging to a particular country, therefore nationality refers to n_name; | SELECT T2.n_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_name = 'Customer#000000055' |
retails | Give customer No.106936's region name. | "Customer#000000055" is the name of the customer which refers to c_name; region name refers to r_name; | SELECT T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_custkey = 106936 |
retails | Give the number of Moroccan customers whose account is in debt. | account is in debt if c_acctbal < 0; Moroccan customers refer to c_name WHERE n_name = 'MOROCCO'; | SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'MOROCCO' AND T1.c_acctbal < 0 |
retails | For the order with the total price of 231499.38, what was the discounted price for supplier No. 9397? | MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)) where o_totalprice = 231499.38 AND l_suppkey = 9397; | SELECT T1.l_extendedprice * (1 - T1.l_discount) AS DISCOUNTERPRICE FROM lineitem AS T1 INNER JOIN orders AS T2 ON T2.o_orderkey = T1.l_orderkey WHERE T1.l_suppkey = 9397 AND T2.o_totalprice = 231499.38 |
retails | For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id. | returned item refers to l_returnflag = 'R'; supplier id refers to l_suppkey; order with the total price of 218195.43 refers to o_totalprice = 218195.43; | SELECT T2.l_suppkey FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_totalprice = 218195.43 AND T2.l_returnflag = 'R' |
retails | Clerk#000000936 dealt with a "Not Specified" order on 1995/3/13, what was the charge for the part of the order shipped by truck? | MULTIPLY(MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)), SUM(1, l_tax)) WHERE o_clerk = 'Clerk#000000936', o_orderstatus = '4-NOT SPECIFIED', o_orderdate = '1995-03-13' AND l_shipmode = 'TRUCK'; | SELECT T2.l_extendedprice * (1 - T2.l_discount) * (1 + T2.l_tax) AS num FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_clerk = 'Clerk#000000936' AND T2.l_shipmode = 'TRUCK' AND T1.o_orderstatus = '4-NOT SPECIFIED' AND T1.o_orderdate = '1995-03-13' |
retails | Customer No.129301 made an order on 1996/7/27, what was the delivery time for the first part of that order? | SUBTRACT(l_receiptdate, l_commitdate) WHERE o_orderdate = '1996-07-27' AND o_custkey = '129301'; | SELECT JULIANDAY(T2.l_receiptdate) - JULIANDAY(T2.l_commitdate) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_custkey = '129301' AND T1.o_orderdate = '1996-07-27' |
retails | Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10. | name of the customer refers to c_name; o_clerk = 'Clerk#000000803'; order on 1997/12/10 refers to o_orderdate = '1997-12-10'; | SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderdate = '1997-12-10' AND T1.o_clerk = 'Clerk#000000803' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.