1sf/bird-sql-train-with-schema huggingface dataset:
Database: regional_sales
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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
Tables: Customers, Products, Regions, Sales Team, Store Locations, Sales Orders
Columns (table index, column name): -1, *, 0, CustomerID, 0, Customer Names, 1, ProductID, 1, Product Name, 2, StateCode, 2, State, 2, Region, 3, SalesTeamID, 3, Sales Team, 3, Region, 4, StoreID, 4, City Name, 4, County, 4, StateCode, 4, State, 4, Type, 4, Latitude, 4, Longitude, 4, AreaCode, 4, Population, 4, Household Income, 4, Median Income, 4, Land Area, 4, Water Area, 4, Time Zone, 5, OrderNumber, 5, Sales Channel, 5, WarehouseCode, 5, ProcuredDate, 5, OrderDate, 5, ShipDate, 5, DeliveryDate, 5, CurrencyCode, 5, _SalesTeamID, 5, _CustomerID, 5, _StoreID, 5, _ProductID, 5, Order Quantity, 5, Discount Applied, 5, Unit Price, 5, Unit Cost
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