Chinastark/bird_dataset huggingface dataset:
Database: regional_sales
Question: Among the sales with 40% discount via in-store channel, how many products were shipped from warehouse code of WARE-NMK1003?
Evidence: 40% discount refers to Discount Applied = 0.4; in-store channel refers to Sales Channel = 'In-Store'; orders refer to OrderNumber;
SQL: SELECT COUNT(DISTINCT T) FROM ( SELECT CASE  WHEN `Sales Channel` = 'In-Store' AND WarehouseCode = 'WARE-NMK1003' AND `Discount Applied` = '0.4' THEN OrderNumber ELSE NULL END AS T FROM `Sales Orders` ) WHERE T IS NOT NULL
Database: regional_sales
Question: Mention the most populated city and median income of the store in Florida state.
Evidence: most populated refers to Max(Population);
SQL: SELECT `City Name`, `Median Income` FROM `Store Locations` WHERE State = 'Florida' ORDER BY Population DESC LIMIT 1
Database: regional_sales
Question: Describe the ID, city and region of the stores which are in Allen country.
Evidence: ID refers to StoreID;
SQL: SELECT DISTINCT T2.StoreID, T2.`City Name`, T1.Region FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.County = 'Allen County'
Database: regional_sales
Question: List the ID, city, state and region for the store type which is fewer between borough and CDP.
Evidence: COUNT(StoreID) < COUNT(StoreID where Type = 'Borough') < COUNT(StoreID where Type = 'CDP');
SQL: SELECT DISTINCT T2.StoreID, T2.`City Name`, T1.State, T2.Type FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.Type = 'Borough' OR T2.Type = 'CDP'
Database: regional_sales
Question: Write down the region and name of the sale team ID of 18 and compare their orders between in-store and online.
Evidence: sale team ID of 18 refers to _SalesTeamID = 18; COUNT(OrderNumber where Sales Channel = 'In-Store') > COUNT(OrderNumber where Sales Channel = 'Online');
SQL: SELECT T2.Region, T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.SalesTeamID = 18 AND T1.`Sales Channel` = 'In-Store' OR T1.`Sales Channel` = 'Online'
Database: regional_sales
Question: Calculate the percentage of order via in-store channel of customer "Medline".
Evidence: Medline is the name of the customer; DIVIDE(COUNT(OrderNumber where Sales Channel = 'In-Store' and Customer Names = 'Medline'), COUNT(OrderNumber where Customer Names = 'Medline')) as percentage;
SQL: SELECT CAST(SUM(CASE WHEN T1.`Sales Channel` = 'In-Store' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1._CustomerID) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Medline '
Database: regional_sales
Question: Describe the customer names and lasting delivery periods for the product of "Bedroom Furniture" by wholesale channel in 2019.
Evidence: delivery period in 2019 means time between placing of an order and the receipt of product and refers to SUBTRACT(DeliveryDate, OrderDate) where SUBSTR(OrderDate, -2 ) = '19'; Sales Channel = 'Wholesale'; Product Name = 'Bedroom Furniture';
SQL: SELECT T1.`Customer Names`, T2.DeliveryDate FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN Products AS T3 ON T3.ProductID = T2._ProductID WHERE T2.`Sales Channel` = 'Wholesale' AND T3.`Product Name` = 'Bedroom Furniture' AND T2.OrderDate LIKE '%/%/19'
Database: regional_sales
Question: Describe the customer names and product names which had over 3800 USD in net profit.
Evidence: over 3800 USD in net profit refers to SUBTRACT(Unit Price, Unit Cost) where Net Profit > 3800;
SQL: SELECT DISTINCT `Customer Names`, `Product Name` FROM ( SELECT T1.`Customer Names`, T3.`Product Name` , REPLACE(T2.`Unit Price`, ',', '') - REPLACE(T2.`Unit Cost`, ',', '') AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID INNER JOIN Products T3 ON T3.ProductID = T2._ProductID ) WHERE T > 3800
Database: regional_sales
Question: List the store located cities with regions in no water area of California state.
Evidence: cities refer to City Name; no water area refers to Water Area = 0;
SQL: SELECT DISTINCT T2.`City Name` FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'California' AND T2.`Water Area` = '0'
Database: regional_sales
Question: Calculate the order percentage by "Carlos Miller" sales team.
Evidence: DIVIDE(COUNT(OrderNumber where Sales Team = 'Carlos Miller'), COUNT(OrderNumber)) as percentage;
SQL: SELECT CAST(SUM(CASE WHEN T2.`Sales Team` = 'Carlos Miller' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID
Database: regional_sales
Question: Compare the number of orders between "Platters" and "Serveware" products.
Evidence: COUNT(OrderNumber where Product Name = 'Platters') > COUNT(OrderNumber where Product Name = 'Serveware');
SQL: SELECT SUM(CASE WHEN T2.`Product Name` = 'Platters' THEN 1 ELSE 0 END) AS num1 , SUM(CASE WHEN T2.`Product Name` = 'Serveware' THEN 1 ELSE 0 END) AS num2 FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID
Database: regional_sales
Question: Calculate the total net profit of the store located in highest median income city.
Evidence: net profit can be computed as SUBTRACT(Unit Price, Unit Cost); highest median income city refers to City Name where MAX(Median Income);
SQL: SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID ORDER BY T2.`Median Income` DESC LIMIT 1
Database: regional_sales
Question: Among the sales team in South region, write down the numbers of orders made by the sales team ID of one digit.
Evidence: sales team ID of one digit refers to _SalesTeamID BETWEEN 1 AND 9; numbers of orders refer to COUNT(OrderNumber);
SQL: SELECT COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.Region = 'South' AND T2.SalesTeamID BETWEEN 1 AND 9 GROUP BY T2.SalesTeamID HAVING COUNT(T1.OrderNumber)
Database: regional_sales
Question: How many orders have order date in 5/31/2018?
Evidence: orders refer to OrderNumber;
SQL: SELECT SUM(IIF(OrderDate = '5/31/18', 1, 0)) FROM `Sales Orders`
Database: regional_sales
Question: List out the name of orders which have delivery date of 6/13/2018.
SQL: SELECT DISTINCT T FROM ( SELECT IIF(DeliveryDate = '6/13/18', OrderNumber, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL
Database: regional_sales
Question: How many orders placed were with more than 5 product quantities?
Evidence: orders refer to OrderNumber; more than 5 product quantities refer to Order Quantity > 5;
SQL: SELECT SUM(IIF(`Order Quantity` > 5, 1, 0)) FROM `Sales Orders`
Database: regional_sales
Question: State the full name of state code "GA".
SQL: SELECT T FROM ( SELECT IIF(StateCode = 'GA', State, NULL) AS T FROM Regions ) WHERE T IS NOT NULL
Database: regional_sales
Question: How many states located in the Midwest region?
SQL: SELECT COUNT(DISTINCT T) FROM ( SELECT CASE  WHEN Region = 'Midwest' THEN StateCode ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL
Database: regional_sales
Question: List out the product name of order which has unit cost of 781.22.
SQL: SELECT T FROM ( SELECT DISTINCT IIF(T1.`Unit Cost` = 781.22, T2.`Product Name`, NULL) AS T FROM `Sales Orders` T1 INNER JOIN Products T2 ON T2.ProductID = T1._ProductID ) WHERE T IS NOT NULL
Database: regional_sales
Question: State the delivery date of cookware.
Evidence: Cookware is the name of the product;
SQL: SELECT T FROM ( SELECT DISTINCT IIF(T2.`Product Name` = 'Cookware', T1.DeliveryDate, NULL) AS T FROM `Sales Orders` T1 INNER JOIN Products T2 ON T2.ProductID = T1._ProductID ) WHERE T IS NOT NULL
Database: regional_sales
Question: How many furniture cushions orders which have date of order in 2018?
Evidence: furniture cushions orders refer to OrderNumber where Product Name = 'Furniture Cushions'; date of order in 2018 refers to SUBSTR(OrderDate, -2) = '18'
SQL: SELECT SUM(CASE WHEN T1.OrderDate LIKE '%/%/18' AND T2.`Product Name` = 'Furniture Cushions' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID
Database: regional_sales
Question: List out the name of products which have been applied 10% discount.
Evidence: applied 10% discount refers to Discount Applied = 0.1;
SQL: SELECT T FROM ( SELECT DISTINCT IIF(T1.`Discount Applied` = 0.1, T2.`Product Name`, NULL) AS T FROM `Sales Orders` T1 INNER JOIN Products T2 ON T2.ProductID = T1._ProductID ) WHERE T IS NOT NULL
Database: regional_sales
Question: Calculate the average net profit of phones which have sales channel of distributor.
Evidence: net profit can be computed as SUBTRACT(Unit Price, Unit Cost); AVG(net profit) where Product Name = 'Phones' and Sales Channel = 'Distributor';
SQL: SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Phones' AND T1.`Sales Channel` = 'Distributor'
Database: regional_sales
Question: Calculate the average net profit of bar tools which has ordered quantity exceed 5.
Evidence: net profit can be computed as SUBTRACT(Unit Price, Unit Cost); AVG(net profit) where Product Name = 'Bar Tools' and Order Quantity > 5;
SQL: SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Bar Tools' AND T1.`Order Quantity` > 5
Database: regional_sales
Question: List out the city name of states located in South region.
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T1.Region = 'South' THEN T2.`City Name` END AS T FROM Regions T1 INNER JOIN `Store Locations` T2 ON T2.StateCode = T1.StateCode ) WHERE T IS NOT NULL
Database: regional_sales
Question: What is the region of stores which have type of "Town" in the list?
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T2.Type = 'Town' THEN T1.Region END AS T FROM Regions T1 INNER JOIN `Store Locations` T2 ON T2.StateCode = T1.StateCode ) WHERE T IS NOT NULL
Database: regional_sales
Question: How many orders that Medsep Group had made?
Evidence: Medsep Group is the name of the customer; orders refer to OrderNumber;
SQL: SELECT SUM(CASE WHEN T1.`Customer Names` = 'Medsep Group' THEN 1 ELSE 0 END) FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID
Database: regional_sales
Question: List out the discount levels applied for all orders from Ole Group.
Evidence: Ole Group is the name of the customer; discount levels applied refer to Discount Applied NOT NULL;
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T1.`Customer Names` = 'Ole Group' THEN T2.`Discount Applied` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL
Database: regional_sales
Question: State the customer name of orders which has shipped date in 7/8/2018.
Evidence: shipped date in 7/8/2018 refers to ShipDate = '7/8/18'
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T2.ShipDate = '7/8/18' THEN T1.`Customer Names` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL
Database: regional_sales
Question: Among the orders placed by Ei, how many orders have quantity greater than 4?
Evidence: Ei is the name of the customer; orders have quantity greater than 4 refer to OrderNumber WHERE Order Quantity > 4;
SQL: SELECT SUM(CASE WHEN T1.`Order Quantity` > 4 AND T2.`Customer Names` = 'Ei ' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID
Database: regional_sales
Question: Among the orders placed by Pacific Ltd, how many orders have been applied 5% discount ?
Evidence: orders by Pacific Ltd refer to OrderNumber where Customer Names = 'Pacific Ltd'; applied 5% discount refers to Discount Applied = 0.05;
SQL: SELECT SUM(CASE WHEN T1.`Discount Applied` = 0.05 AND T2.`Customer Names` = 'Pacific Ltd' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID
Database: regional_sales
Question: What is the customer names of orders which have unit cost greater than 4000USD?
Evidence: unit cost greater than 4000USD refers to Unit Cost > 4000;
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T2.`Unit Cost` > 4000 THEN T1.`Customer Names` END AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) WHERE T IS NOT NULL
Database: regional_sales
Question: Please list the id and detailed position of all stores in Birmingham city.
Evidence: Latitude and Longitude coordinates can be used to identify the detailed position of stores; id refers to StoreID;
SQL: SELECT StoreID, Latitude, Longitude FROM `Store Locations` WHERE `City Name` = 'Birmingham'
Database: regional_sales
Question: Which city has the largest population?
Evidence: city has the largest population refers to City Name where MAX(Population);
SQL: SELECT `City Name` FROM `Store Locations` ORDER BY Population DESC LIMIT 1
Database: regional_sales
Question: How many CDP stores are there in California?
Evidence: California is a state; CDP stores refer to StoreID where Type = 'CDP';
SQL: SELECT SUM(CASE WHEN State = 'California' AND Type = 'CDP' THEN 1 ELSE 0 END) FROM `Store Locations`
Database: regional_sales
Question: Please give the order number and product name of the order which has the lowest unit price.
Evidence: the lowest unit price refers to MIN(Unit Price);
SQL: SELECT T1.OrderNumber, T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE REPLACE(T1.`Unit Price`, ',', '') = ( SELECT REPLACE(T1.`Unit Price`, ',', '') FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID ORDER BY REPLACE(T1.`Unit Price`, ',', '') LIMIT 1 )
Database: regional_sales
Question: Which product has the highest net profit in 2019?
Evidence: net profit can be computed as SUBTRACT(Unit Price, Unit Cost); the highest net profit in 2019 refers to MAX(Net Profit) where OrderDate LIKE '%/19'; product refers to Product Name;
SQL: SELECT T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.OrderDate LIKE '%/%/19' ORDER BY REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') DESC LIMIT 1
Database: regional_sales
Question: What is the average unit price of a Cookware product?
Evidence: AVG(Unit Price where Product Name = 'Cookware');
SQL: SELECT AVG(REPLACE(T1.`Unit Price`, ',', '')) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T2.`Product Name` = 'Cookware'
Database: regional_sales
Question: Please list all sale team names which had orders on 5/31/2018.
Evidence: had orders on 5/31/2018 refer to OrderDate = '5/31/18'; sale team names refer to Sales Team;
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T1.OrderDate = '5/31/18' THEN T2.`Sales Team` ELSE NULL END AS T FROM `Sales Orders` T1 INNER JOIN `Sales Team` T2 ON T2.SalesTeamID = T1._SalesTeamID ) WHERE T IS NOT NULL
Database: regional_sales
Question: Which sales team name has the least orders in 2019?
Evidence: sale team names refer to Sales Team; the least orders in 2019 refer to MIN(COUNT(OrderNumber where SUBSTR(OrderDate, -2) = '19'));
SQL: SELECT T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.OrderDate LIKE '%/%/19' GROUP BY T2.`Sales Team` ORDER BY COUNT(T1.OrderNumber) ASC LIMIT 1
Database: regional_sales
Question: From 2018 to 2020, which year did the George Lewis group have the highest number of orders?
Evidence: George Lewis refers to Sales Team; the highest number of orders refers to MAX(COUNT(OrderNumber)); which year from 2018 to 2020 refers to SUBSTR(OrderDate, -2) IN ('18', '19', '20') GROUP BY SUBSTR(OrderDate, -2);
SQL: SELECT SUBSTR(T1.OrderDate, -2, 2) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.`Sales Team` = 'George Lewis' GROUP BY SUBSTR(T1.OrderDate, -2, 2) ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1
Database: regional_sales
Question: What is the percentage of total orders from stores in Orange County in 2018?
Evidence: DIVIDE(COUNT(OrderNumber where County = 'Orange County' and SUBSTR(OrderDate, -2) = '18'), COUNT(OrderNumber where SUBSTR(OrderDate, -2) = '18')) as percentage;
SQL: SELECT CAST(SUM(CASE WHEN T2.County = 'Orange County' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.OrderDate LIKE '%/%/18'
Database: regional_sales
Question: Which order number has the highest unit price?
Evidence: the highest unit price refers to MAX(Unit Price);
SQL: SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Price`, ',', '') = ( SELECT REPLACE(`Unit Price`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Price`, ',', '') DESC LIMIT 1 )
Database: regional_sales
Question: Which sales team id has the highest number of orders in 2018?
Evidence: the highest number of orders in 2018 refers to MAX(COUNT(OrderNumber where SUBSTR(OrderDate, -2) = '18'));
SQL: SELECT _SalesTeamID FROM `Sales Orders` WHERE OrderDate LIKE '%/%/18' GROUP BY _SalesTeamID ORDER BY COUNT(_SalesTeamID) DESC LIMIT 1
Database: regional_sales
Question: What is the unit cost of order SO - 000103?
Evidence: OrderNumber = 'SO - 000103';
SQL: SELECT DISTINCT T FROM ( SELECT IIF(OrderNumber = 'SO - 000103', `Unit Cost`, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL
Database: regional_sales
Question: In 2020, what were the total orders of all stores in Maricopa County?
Evidence: total orders refer to COUNT(OrderNumber); 2020 refers to SUBSTR(OrderDate, -2) = '20';
SQL: SELECT SUM(CASE WHEN T2.County = 'Maricopa County' AND OrderDate LIKE '%/%/20' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID
Database: regional_sales
Question: What is the detailed position of the store which has order SO - 000115?
Evidence: Latitude and Longitude coordinates can be used to identify the detailed position of stores; store refers to StoreID WHERE OrderNumber = 'SO - 000115';
SQL: SELECT T2.Latitude, T2.Longitude FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.OrderNumber = 'SO - 000115'
Database: regional_sales
Question: Please calculate the total number of orders by each city in 2019.
Evidence: total number of orders refers to COUNT(OrderNumber); 2019 refers to OrderDate between 01-01-2019 and 31-12-2019; city refers to City Name;
SQL: SELECT COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.OrderDate LIKE '%/%/19' GROUP BY T2.`City Name` HAVING COUNT(T1.OrderNumber)
Database: regional_sales
Question: Please list the names of customers who have total orders of over 3 in 2018.
Evidence: total orders of over 3 in 2018 refer to COUNT(OrderNumber) > 3 where SUBSTR(OrderDate, -2) = '18';
SQL: SELECT DISTINCT IIF(COUNT(T2.CustomerID) > 3, T2.`Customer Names`, NULL) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T1.OrderDate LIKE '%/%/18' GROUP BY T1._CustomerID HAVING COUNT(T2.CustomerID)
Database: regional_sales
Question: What were the total orders of Medsep Group from 2018 to 2020?
Evidence: Medsep Group is the name of the customer; total orders refer to COUNT(OrderNumber); from 2018 to 2020 refers to SUBSTR(OrderDate, -2) IN ('18', '19', '20');
SQL: SELECT SUM(CASE WHEN SUBSTR(T1.OrderDate, -2) IN ('18', '19', '20') AND T2.`Customer Names` = 'Medsep Group' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID
Database: regional_sales
Question: Please list the customer names whose order quantity was more than 5 on 6/1/2018.
Evidence: order quantity was more than 5 on 6/1/2018 refers to Order Quantity > 5 where OrderDate = 6/1/2018;
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN SUM(T1.`Order Quantity`) > 5 THEN T2.`Customer Names` END AS T FROM `Sales Orders` T1 INNER JOIN Customers T2 ON T2.CustomerID = T1._CustomerID WHERE T1.OrderDate = '6/1/18' GROUP BY T1._CustomerID ) WHERE T IS NOT NULL
Database: regional_sales
Question: What is the percentage of total orders of Stephen Payne that had a net profit of over 1000?
Evidence: Sales Team = 'Stephen Payne'; net profit can be computed as SUBTRACT(Unit Price, Unit Cost); DIVIDE(COUNT(OrderNumber where Sales Team = 'Stephen Payne' and Net Profit > 1000)), (COUNT(OrderNumber where Sales Team = 'Stephen Payne')) as percentage;
SQL: SELECT CAST(SUM(CASE WHEN REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') > 1000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.`Sales Team` = 'Stephen Payne'
Database: regional_sales
Question: How many sales team were from Northeast?
Evidence: Northeast is the name of the region;
SQL: SELECT SUM(CASE WHEN Region = 'Northeast' THEN 1 ELSE 0 END) FROM `Sales Team`
Database: regional_sales
Question: State the name of all city in Maricopa County along with its latitude and longitude.
SQL: SELECT DISTINCT `City Name`, Latitude, Longitude FROM `Store Locations` WHERE County = 'Maricopa County'
Database: regional_sales
Question: Which order have the highest unit cost?
Evidence: order have the highest unit cost refers to OrderNumber where MAX(Unit Cost);
SQL: SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 )
Database: regional_sales
Question: List all the name of products with the ID of 30 to 40.
Evidence: products with the ID of 30 to 40 refer to Product Name WHERE ProductID BETWEEN 30 AND 40;
SQL: SELECT T FROM ( SELECT CASE  WHEN ProductID BETWEEN 30 AND 40 THEN `Product Name` ELSE NULL END AS T FROM Products ) WHERE T IS NOT NULL
Database: regional_sales
Question: Calculate ratio between the highest unit cost and the lowest unit cost?
Evidence: ratio can be calculated as DIVIDE(MAX(Unit_Cost)), MIN(Unit Cost);
SQL: SELECT ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 ) ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 ) / ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') ASC LIMIT 1 ) ORDER BY REPLACE(`Unit Cost`, ',', '') ASC LIMIT 1 )
Database: regional_sales
Question: Which product was ordered the most in 2018?
Evidence: product refers to Product Name; ordered the most in 2018 refers to MAX(COUNT(OrderNumber)) where SUBSTR(OrderDate, -2) = '18';
SQL: SELECT T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.OrderDate LIKE '%/%/18' GROUP BY T1._ProductID ORDER BY COUNT(T1._ProductID) DESC LIMIT 1
Database: regional_sales
Question: How many products sold by Adam Hernandez?
Evidence: products sold by Adam Hernandez refer to SUM(Order Quantity where Sales Team = 'Adam Hernandez');
SQL: SELECT SUM(CASE WHEN T2.`Sales Team` = 'Adam Hernandez' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID
Database: regional_sales
Question: List all orders where its products were shipped from Daly City.
Evidence: shipped from Daly City refers to Store Locations where City Name = 'Daly City'; orders refer to OrderNumber;
SQL: SELECT T FROM ( SELECT DISTINCT CASE  WHEN T2.`City Name` = 'Daly City' THEN T1.OrderNumber END AS T FROM `Sales Orders` T1 INNER JOIN `Store Locations` T2 ON T2.StoreID = T1._StoreID ) WHERE T IS NOT NULL