input
stringlengths 358
16.1k
| output
stringlengths 24
805
|
---|---|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List the store located cities with regions in no water area of California state. [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the order percentage by "Carlos Miller" sales team. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Compare the number of orders between "Platters" and "Serveware" products. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the total net profit of the store located in highest median income city. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Among the sales team in South region, write down the numbers of orders made by the sales team ID of one digit. [/INST] | 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); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many orders have order date in 5/31/2018? [/INST] | SELECT SUM(IIF(OrderDate = '5/31/18', 1, 0)) FROM `Sales Orders`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List out the name of orders which have delivery date of 6/13/2018. [/INST] | SELECT DISTINCT T FROM ( SELECT IIF(DeliveryDate = '6/13/18', OrderNumber, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many orders placed were with more than 5 product quantities? [/INST] | SELECT SUM(IIF(`Order Quantity` > 5, 1, 0)) FROM `Sales Orders`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State the full name of state code "GA". [/INST] | SELECT T FROM ( SELECT IIF(StateCode = 'GA', State, NULL) AS T FROM Regions ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many states located in the Midwest region? [/INST] | SELECT COUNT(DISTINCT T) FROM ( SELECT CASE WHEN Region = 'Midwest' THEN StateCode ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List out the product name of order which has unit cost of 781.22. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State the delivery date of cookware. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many furniture cushions orders which have date of order in 2018? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List out the name of products which have been applied 10% discount. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the average net profit of phones which have sales channel of distributor. [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the average net profit of bar tools which has ordered quantity exceed 5. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List out the city name of states located in South region. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the region of stores which have type of "Town" in the list? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many orders that Medsep Group had made? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List out the discount levels applied for all orders from Ole Group. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State the customer name of orders which has shipped date in 7/8/2018. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Among the orders placed by Ei, how many orders have quantity greater than 4? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Among the orders placed by Pacific Ltd, how many orders have been applied 5% discount ? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the customer names of orders which have unit cost greater than 4000USD? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the id and detailed position of all stores in Birmingham city. [/INST] | SELECT StoreID, Latitude, Longitude FROM `Store Locations` WHERE `City Name` = 'Birmingham'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which city has the largest population? [/INST] | SELECT `City Name` FROM `Store Locations` ORDER BY Population DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many CDP stores are there in California? [/INST] | SELECT SUM(CASE WHEN State = 'California' AND Type = 'CDP' THEN 1 ELSE 0 END) FROM `Store Locations`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please give the order number and product name of the order which has the lowest unit price. [/INST] | 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 ); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which product has the highest net profit in 2019? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average unit price of a Cookware product? [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please list all sale team names which had orders on 5/31/2018. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which sales team name has the least orders in 2019? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: From 2018 to 2020, which year did the George Lewis group have the highest number of orders? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the percentage of total orders from stores in Orange County in 2018? [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which order number has the highest unit price? [/INST] | SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Price`, ',', '') = ( SELECT REPLACE(`Unit Price`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Price`, ',', '') DESC LIMIT 1 ); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which sales team id has the highest number of orders in 2018? [/INST] | SELECT _SalesTeamID FROM `Sales Orders` WHERE OrderDate LIKE '%/%/18' GROUP BY _SalesTeamID ORDER BY COUNT(_SalesTeamID) DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the unit cost of order SO - 000103? [/INST] | SELECT DISTINCT T FROM ( SELECT IIF(OrderNumber = 'SO - 000103', `Unit Cost`, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: In 2020, what were the total orders of all stores in Maricopa County? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the detailed position of the store which has order SO - 000115? [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please calculate the total number of orders by each city in 2019. [/INST] | 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); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the names of customers who have total orders of over 3 in 2018. [/INST] | 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); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What were the total orders of Medsep Group from 2018 to 2020? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the customer names whose order quantity was more than 5 on 6/1/2018. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the percentage of total orders of Stephen Payne that had a net profit of over 1000? [/INST] | 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'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many sales team were from Northeast? [/INST] | SELECT SUM(CASE WHEN Region = 'Northeast' THEN 1 ELSE 0 END) FROM `Sales Team`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State the name of all city in Maricopa County along with its latitude and longitude. [/INST] | SELECT DISTINCT `City Name`, Latitude, Longitude FROM `Store Locations` WHERE County = 'Maricopa County'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which order have the highest unit cost? [/INST] | SELECT OrderNumber FROM `Sales Orders` WHERE REPLACE(`Unit Cost`, ',', '') = ( SELECT REPLACE(`Unit Cost`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Cost`, ',', '') DESC LIMIT 1 ); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List all the name of products with the ID of 30 to 40. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate ratio between the highest unit cost and the lowest unit cost? [/INST] | 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 ); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Which product was ordered the most in 2018? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many products sold by Adam Hernandez? [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List all orders where its products were shipped from Daly City. [/INST] | 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many orders made by Rochester Ltd? [/INST] | SELECT SUM(CASE WHEN T1.`Customer Names` = 'Rochester Ltd' THEN 1 ELSE 0 END) FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State the order number where Qualitest ordered the highest product quantity. [/INST] | SELECT T1.OrderNumber FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Qualitest ' ORDER BY T1.`Order Quantity` DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List the order for all in-store sales along with the products sold. [/INST] | SELECT DISTINCT T1.OrderNumber, T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.`Sales Channel` = 'In-Store'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many online sales were made in May 2018 where products were shipped from Norman? [/INST] | SELECT SUM(CASE WHEN T1.OrderDate LIKE '5/%/18' AND T1.`Sales Channel` = 'Online' AND T2.`City Name` = 'Norman' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Among the products sold in Maricopa County, which was the least sold? [/INST] | SELECT T1.`Product Name` FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T3.County = 'Maricopa County' ORDER BY T2.`Order Quantity` ASC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: State all the order numbers for sales team of Samuel Fowler. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.`Sales Team` = 'Samuel Fowler' THEN T1.OrderNumber ELSE NULL END AS T FROM `Sales Orders` T1 INNER JOIN `Sales Team` T2 ON T2.SalesTeamID = T1._SalesTeamID ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the number of baseball ordered in December 2017. [/INST] | SELECT COUNT(T2.OrderNumber) FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID WHERE T1.`Product Name` = 'Baseball' AND T2.OrderDate LIKE '12/%/18'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the average number of ornaments sold each month in 2018. [/INST] | SELECT CAST(SUM(T2.`Order Quantity`) AS REAL) / 12 FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID WHERE T1.`Product Name` = 'Ornaments' AND T2.OrderDate LIKE '%/%/18'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the percentage of products that were shipped from Burbank in 2018? [/INST] | SELECT CAST(SUM(CASE WHEN T3.`City Name` = 'Burbank' THEN T2.`Order Quantity` ELSE 0 END) AS REAL) * 100 / SUM(T2.`Order Quantity`) FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T2.OrderDate LIKE '%/%/18'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the difference in order number from "WARE-MKL1006" and "WARE-NBV1002"? [/INST] | SELECT SUM(IIF(WarehouseCode = 'WARE-MKL1006', 1, 0)) - SUM(IIF(WarehouseCode = 'WARE-NBV1002', 1, 0)) AS difference FROM `Sales Orders`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Describe the product names delivered in 2021 for the customer "Sundial". [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.DeliveryDate LIKE '%/%/21' AND T1.`Customer Names` = 'Sundial ' THEN T3.`Product Name` END 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 IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Write down the store IDs and region of the state "Michigan". [/INST] | SELECT DISTINCT T2.StoreID, T1.Region FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'Michigan'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Compare the total number of orders between customer "Apollo Ltd" and "Pacific Ltd". [/INST] | SELECT SUM(CASE WHEN T2.`Customer Names` = 'Apollo Ltd' THEN 1 ELSE 0 END), SUM(CASE WHEN 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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the store ID with more orders between "Aurora" and "Babylon" city. [/INST] | SELECT T2.StoreID FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.`City Name` = 'Aurora (Township)' OR T2.`City Name` = 'Babylon (Town)' GROUP BY T2.StoreID ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List down the customer names and product names of the order made by "Anthony Torres" via distributor channel. [/INST] | SELECT DISTINCT T1.`Customer Names`, T4.`Product Name` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID INNER JOIN Products AS T4 ON T4.ProductID = T2._ProductID WHERE T3.`Sales Team` = 'Anthony Torres' AND T2.`Sales Channel` = 'Distributor'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Mention the customer names and IDs which ordered total net profit of above 5000 USD through online channel. [/INST] | SELECT DISTINCT `Customer Names`, CustomerID FROM ( SELECT T2.`Customer Names`, T2.CustomerID , SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) AS T FROM `Sales Orders` T1 INNER JOIN Customers T2 ON T2.CustomerID = T1._CustomerID WHERE T1.`Sales Channel` = 'Online' GROUP BY T2.CustomerID ) WHERE T > 5000; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the net profit of the floral products which were delivered in 2021. [/INST] | SELECT SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.DeliveryDate LIKE '%/%/21' AND T2.`Product Name` = 'Floral'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Count the number of orders made from the store in city with population of 3000000 to 4000000. [/INST] | SELECT COUNT(T1.OrderNumber) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.Population BETWEEN 3000000 AND 4000000; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Name the products via wholesale channel of the store under Pacific/Honolulu time zone. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T3.`Time Zone` = 'Pacific/Honolulu' AND T2.`Sales Channel` = 'Wholesale' THEN T1.`Product Name` ELSE NULL END AS T FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` T3 ON T3.StoreID = T2._StoreID ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List the order numbers and product names which were ordered on 6th June, 2018. [/INST] | SELECT DISTINCT OrderNumber, `Product Name` FROM ( SELECT IIF(T2.OrderDate = '6/6/18', T2.OrderNumber, NULL) AS "OrderNumber" , IIF(T2.OrderDate = '6/6/18', T1.`Product Name`, NULL) AS "Product Name" FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID ) WHERE OrderNumber IS NOT NULL AND `Product Name` IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Find the average yearly order by customer Weimei Corp for 2018, 2019 and 2020. [/INST] | SELECT COUNT(T1.OrderNumber) / 3 FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE (T1.OrderDate LIKE '%/%/18' AND T2.`Customer Names` = 'Weimei Corp') OR (T1.OrderDate LIKE '%/%/19' AND T2.`Customer Names` = 'Weimei Corp') OR (T1.OrderDate LIKE '%/%/20' AND T2.`Customer Names` = 'Weimei Corp'); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the average monthly order and percentage of warehouse "WARE-NMK1003" in 2019. Among them, mention number of orders for floor lamps. [/INST] | SELECT CAST(SUM(CASE WHEN T2.WarehouseCode = 'WARE-NMK1003' THEN 1 ELSE 0 END) AS REAL) / 12 , CAST(SUM(CASE WHEN T2.WarehouseCode = 'WARE-NMK1003' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.OrderNumber), COUNT(CASE WHEN T1.`Product Name` = 'Floor Lamps' AND T2.WarehouseCode = 'WARE-NMK1003' THEN T2.`Order Quantity` ELSE NULL END) FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID WHERE T2.OrderDate LIKE '%/%/19'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Indicate the procured dates for the customer whose ID is 11. [/INST] | SELECT DISTINCT T FROM ( SELECT IIF(_CustomerID = 11, ProcuredDate, NULL) AS T FROM `Sales Orders` ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many orders through distributor were for the minimum quantity? [/INST] | SELECT SUM(CASE WHEN `Order Quantity` = 1 AND `Sales Channel` = 'Distributor' THEN 1 ELSE 0 END) FROM `Sales Orders`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List by ID all sales teams that have sold products at a 10% discount in store. [/INST] | SELECT DISTINCT T FROM ( SELECT CASE WHEN `Discount Applied` = '0.1' AND `Sales Channel` = 'In-Store' THEN _SalesTeamID ELSE NULL END AS T FROM `Sales Orders` ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many Borough-type stores located in the city of Brooklyn have a population of less than 3 million? [/INST] | SELECT SUM(CASE WHEN Population < 3000000 AND Type = 'Borough' AND `City Name` = 'Brooklyn' THEN 1 ELSE 0 END) FROM `Store Locations`; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many states are in the Midwest region? [/INST] | SELECT COUNT(DISTINCT T) FROM ( SELECT CASE WHEN Region = 'Midwest' THEN State ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What are the top 10 products with the highest net profit? [/INST] | SELECT T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID GROUP BY T1._ProductID ORDER BY SUM(REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '')) DESC LIMIT 10; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Indicate the name of the customers who have placed an order of 3 units in February 2018. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.`Order Quantity` = 3 AND T2.OrderDate LIKE '2/%/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; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What are the names of the sales teams that have served to customer Apotheca, Ltd? [/INST] | SELECT DISTINCT T3.`Sales Team` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID WHERE T1.`Customer Names` = 'Apotheca, Ltd'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: In which regions are the stores that have shipped products through the WARE-UHY1004 warehouse? [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T3.WarehouseCode = 'WARE-UHY1004' THEN T1.Region END AS T FROM Regions T1 INNER JOIN `Store Locations` T2 ON T2.StateCode = T1.StateCode INNER JOIN `Sales Orders` T3 ON T3._StoreID = T2.StoreID ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List all the cities where Shawn Torres sells Audio products. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T4.`Product Name` = 'Audio' AND T3.`Sales Team` = 'Shawn Torres' THEN T1.`City Name` ELSE NULL END AS T FROM `Store Locations` T1 INNER JOIN `Sales Orders` T2 ON T2._StoreID = T1.StoreID INNER JOIN `Sales Team` T3 ON T3.SalesTeamID = T2._SalesTeamID INNER JOIN Products T4 ON T4.ProductID = T2._ProductID ) WHERE T IS NOT NULL; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: Lists the name of the product and customer who placed an order on 10/21/18 and it was delivered on 11/21/19. [/INST] | SELECT T3.`Product Name`, T1.`Customer Names` 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.OrderDate = '10/21/18' AND T2.DeliveryDate = '11/21/19'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many stores procured products on October 27, 2018, in the city of Oregon? [/INST] | SELECT SUM(CASE WHEN T1.ProcuredDate = '10/27/18' AND T2.`City Name` = 'Orlando' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What sales channels are used the most in the 3 places with the highest median income? [/INST] | SELECT `Sales Channel` FROM ( SELECT T1.`Sales Channel` FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID ORDER BY T2.`Median Income` DESC LIMIT 3 ) GROUP BY `Sales Channel` ORDER BY COUNT(`Sales Channel`) DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: List the 5 sales teams that have made sales with the highest net profits. [/INST] | SELECT T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID ORDER BY REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') DESC LIMIT 5; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the highest discount applied by the store located in a city of the state of Colorado whose land area is 111039036. [/INST] | SELECT MAX(T1.`Discount Applied`) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.State = 'Colorado' AND T2.`Land Area` = 111039036; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many different time zones are there in the Northeast region? [/INST] | SELECT COUNT(DISTINCT T2.`Time Zone`) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T1.Region = 'Northeast'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What type of store is most popular in the South? [/INST] | SELECT DISTINCT CASE WHEN MAX(T2.Population) THEN T2.Type END FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: To which region does the sales team that has used the WARE-MKL1006 warehouse the most times for its shipments belong? [/INST] | SELECT T2.Region FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.WarehouseCode = 'WARE-MKL1006' GROUP BY T2.Region ORDER BY COUNT(T1.OrderNumber) DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: In which city is the store with the highest sales order unit price located? [/INST] | SELECT T2.`City Name` FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE REPLACE(T1.`Unit Price`, ',', '') = ( SELECT REPLACE(T1.`Unit Price`, ',', '') FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID ORDER BY REPLACE(T1.`Unit Price`, ',', '') DESC LIMIT 1 ) ORDER BY REPLACE(T1.`Unit Price`, ',', '') DESC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many online purchases did Ole Group make in May 2019? [/INST] | SELECT SUM(CASE WHEN T1.`Sales Channel` = 'Online' AND T2.`Customer Names` = 'Ole Group' AND T1.OrderDate LIKE '5/%/19' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: How many stores with less need for products, and purchased through a distributor, are located in Washtenaw County? [/INST] | SELECT SUM(CASE WHEN T1.`Order Quantity` = 1 AND T1.`Sales Channel` = 'Distributor' AND T2.County = 'Washtenaw County' THEN 1 ELSE 0 END) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the least purchased product by stores in the city of Santa Clarita? [/INST] | SELECT T1.`Product Name` FROM Products AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._ProductID = T1.ProductID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T3.`City Name` = 'Santa Clarita' GROUP BY T1.`Product Name` ORDER BY COUNT(T1.`Product Name`) ASC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: At what Latitude and Longitude is the store that has used the WARE-PUJ1005 warehouse the fewest times? [/INST] | SELECT T2.Latitude, T2.Longitude FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.WarehouseCode = 'WARE-PUJ1005' GROUP BY T2.StoreID ORDER BY COUNT(T1.WarehouseCode) ASC LIMIT 1; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What percentage of sell orders on 04/04/2020 were for the state of New York? [/INST] | SELECT CAST(SUM(CASE WHEN T2.State = 'New York' 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 = '4/4/20'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average land area of the cities in which stores that purchased products for a unit price of 998.30 are located? [/INST] | SELECT AVG(T2.`Land Area`) FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T1.`Unit Price` = '998.30'; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
Customer Names [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Product Name [ TEXT ]
Regions :
StateCode [ TEXT ] primary_key
State [ TEXT ]
Region [ TEXT ]
Sales Team :
SalesTeamID [ INTEGER ] primary_key
Sales Team [ TEXT ]
Region [ TEXT ]
Store Locations :
StoreID [ INTEGER ] primary_key
City Name [ TEXT ]
County [ TEXT ]
StateCode [ TEXT ] Store Locations.StateCode = Regions.StateCode
State [ TEXT ]
Type [ TEXT ]
Latitude [ REAL ]
Longitude [ REAL ]
AreaCode [ INTEGER ]
Population [ INTEGER ]
Household Income [ INTEGER ]
Median Income [ INTEGER ]
Land Area [ INTEGER ]
Water Area [ INTEGER ]
Time Zone [ TEXT ]
Sales Orders :
OrderNumber [ TEXT ] primary_key
Sales Channel [ TEXT ]
WarehouseCode [ TEXT ]
ProcuredDate [ TEXT ]
OrderDate [ TEXT ]
ShipDate [ TEXT ]
DeliveryDate [ TEXT ]
CurrencyCode [ TEXT ]
_SalesTeamID [ INTEGER ] Sales Orders._SalesTeamID = Sales Team.SalesTeamID
_CustomerID [ INTEGER ] Sales Orders._CustomerID = Customers.CustomerID
_StoreID [ INTEGER ] Sales Orders._StoreID = Store Locations.StoreID
_ProductID [ INTEGER ] Sales Orders._ProductID = Products.ProductID
Order Quantity [ INTEGER ]
Discount Applied [ REAL ]
Unit Price [ TEXT ]
Unit Cost [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average household income in cities in the state of New Hampshire where there are stores of the type city? [/INST] | SELECT AVG(T2.`Household Income`) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T2.State = 'New Hampshire' AND T2.Type = 'City'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.