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: How many sales teams are there in the Midwest? [/INST] | SELECT SUM(CASE WHEN Region = 'Midwest' 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: Indicate order numbers with an order date after 1/1/2018. [/INST] | SELECT DISTINCT T FROM ( SELECT CASE WHEN OrderDate > '1/1/18' THEN OrderNumber 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 sales channels does the sales team have in the Midwest? [/INST] | SELECT COUNT(T1.`Sales Channel`) FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.Region = 'Midwest'; |
[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 has the other with the highest unit price? [/INST] | SELECT T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE REPLACE(T1.`Unit Price`, ',', '') = ( SELECT REPLACE(T1.`Unit Price`, ',', '') FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID 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: Which regions have online sales channels that have the most discounts? [/INST] | SELECT T2.Region FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.`Sales Channel` = 'Online' ORDER BY T1.`Discount Applied` 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 Apollo Ltd customer's order number has the most expensive unit price, indicating the order date? [/INST] | SELECT T1.OrderNumber, T1.OrderDate FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Apollo Ltd' ORDER BY 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: Provide order number, warehouse code of customers Elorac, Corp. [/INST] | SELECT DISTINCT T1.OrderNumber, T1.WarehouseCode FROM `Sales Orders` AS T1 INNER JOIN Customers AS T2 ON T2.CustomerID = T1._CustomerID WHERE T2.`Customer Names` = 'Elorac, 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: Name of customers who have ordered Cocktail Glasses by online sales channel. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T3.`Product Name` = 'Cocktail Glasses' AND T2.`Sales Channel` = 'Online' THEN T1.`Customer Names` 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: Which store in Arizona has the most net profit? [/INST] | SELECT T2.StoreID FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID WHERE T2.State = 'Arizona' ORDER BY T1.`Unit Price` - 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: How much more is the Florida store's computer product unit price than the Texas store? [/INST] | SELECT SUM(CASE WHEN T3.State = 'Florida' THEN T2.`Unit Price` ELSE 0 END) - SUM(CASE WHEN T3.State = 'Texas' THEN T2.`Unit Price` ELSE 0 END) 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 T1.`Product Name` = 'Computers'; |
[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 sales teams in Midwest region, which sales team has an order quantity greater than 5? [/INST] | SELECT DISTINCT T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T2.Region = 'Midwest' 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: Please indicate store id in the state of California that have been applied 20% discount in store. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.State = 'California' AND T1.`Sales Channel` = 'In-Store' AND T1.`Discount Applied` = 0.2 THEN T2.StoreID 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: List the name of the customer with the most number of order quantity from 2018 to 2020. [/INST] | SELECT T1.`Customer Names` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID WHERE T2.OrderDate LIKE '%/%/18' OR T2.OrderDate LIKE '%/%/19' OR T2.OrderDate LIKE '%/%/20' ORDER BY T2.`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: Please indicate total order quantity of product Candles and calculate the percentage of such product among all the orders. [/INST] | SELECT SUM(CASE WHEN T1.`Product Name` = 'Candles' THEN T2.`Order Quantity` ELSE 0 END), CAST(SUM(CASE WHEN T1.`Product Name` = 'Candles' 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; |
[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 region is Joshua Bennet located in? [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN `Sales Team` = 'Joshua Bennett' THEN Region ELSE NULL END AS T FROM `Sales Team` ) 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 store id of the store located in the most populous county? [/INST] | SELECT CASE WHEN MAX(Population) THEN StoreID 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 sales teams are there in the Midwest? [/INST] | SELECT SUM(CASE WHEN Region = 'Midwest' 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: What is the type of store located in the city with the highest amount of water area? [/INST] | SELECT CASE WHEN MAX(`Water Area`) THEN Type 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 online orders were shipped during the month of June 2018? [/INST] | SELECT SUM(IIF(ShipDate LIKE '6/%/18' AND `Sales Channel` = 'Online', 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: How much is the discount applied to the order with the highest unit price? [/INST] | SELECT `Discount Applied` FROM `Sales Orders` WHERE REPLACE(`Unit Price`, ',', '') = ( SELECT REPLACE(`Unit Price`, ',', '') FROM `Sales Orders` ORDER BY REPLACE(`Unit Price`, ',', '') DESC LIMIT 1 ) 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: What is the name of the product 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 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: In the Northeast region, what is the average household income for each city located in the state with the highest number of stores? [/INST] | SELECT AVG(T2.`Household Income`) FROM Regions AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StateCode = T1.StateCode WHERE T1.Region = 'Northeast' GROUP BY T2.State ORDER BY COUNT(T2.StoreID) 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 region can you find the stores located in the state whose median income is no more than 30,000? [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.`Median Income` < 30000 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: In the West, how many stores are there in the city whose land area is below 20,000,000? [/INST] | SELECT SUM(CASE WHEN T1.Region = 'West' AND T2.`Land Area` < 20000000 THEN 1 ELSE 0 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: What is the name of the customer who purchased the product with the highest net profiit? [/INST] | SELECT `Customer Names` FROM ( SELECT T1.`Customer Names`, T2.`Unit Price` - T2.`Unit Cost` AS "net profit" FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) ORDER BY `net profit` 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 2019, how many orders were shipped by the sales team with the highest number of orders in the said year? Provide the name of the sales team. [/INST] | SELECT COUNT(T1.OrderNumber), T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.OrderDate LIKE '%/%/19' AND T1.ShipDate LIKE '%/%/19' GROUP BY T2.`Sales Team` 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: Among the products with an order quantity of no less than 5 that was shipped in the month of May 2019, what is the name of the product with the lowest net profit? [/INST] | SELECT T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID WHERE T1.`Order Quantity` > 5 AND ShipDate LIKE '5/%/19' ORDER BY REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`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: What is the detailed coordinates of the store where the product with the 4th highest profit were purchased from? [/INST] | SELECT T2.Latitude, T2.Longitude FROM `Sales Orders` AS T1 INNER JOIN `Store Locations` AS T2 ON T2.StoreID = T1._StoreID ORDER BY REPLACE(T1.`Unit Price`, ',', '') - REPLACE(T1.`Unit Cost`, ',', '') DESC LIMIT 3, 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 orders were shipped by the sales team with the highest amount of shipped orders in 2020? Give the name of the said sales team. [/INST] | SELECT COUNT(T1.OrderNumber), T2.`Sales Team` FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE T1.ShipDate LIKE '%/%/20' GROUP BY T2.`Sales Team` 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: Between 2018 to 2020, what is the average amount of shipped orders per year under Carl Nguyen? [/INST] | SELECT CAST(COUNT(T1.OrderNumber) AS REAL) / 3 FROM `Sales Orders` AS T1 INNER JOIN `Sales Team` AS T2 ON T2.SalesTeamID = T1._SalesTeamID WHERE (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/18') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/19') OR (T2.`Sales Team` = 'Carl Nguyen' AND ShipDate LIKE '%/%/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 amount of discount applied to the product with the highest net profit and what is the name of the said product? [/INST] | SELECT T1.`Unit Price` * T1.`Discount Applied`, T2.`Product Name` FROM `Sales Orders` AS T1 INNER JOIN Products AS T2 ON T2.ProductID = T1._ProductID 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 are the names of the top 3 customers who paid the highest amount of price per order after discount? [/INST] | SELECT `Customer Names` FROM ( SELECT T1.`Customer Names` , REPLACE(T2.`Unit Price`, ',', '') * T2.`Order Quantity` - REPLACE(T2.`Unit Price`, ',', '') * T2.`Discount Applied` AS T FROM Customers T1 INNER JOIN `Sales Orders` T2 ON T2._CustomerID = T1.CustomerID ) ORDER BY T DESC LIMIT 3; |
[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 channel was most preferred in commercializing products in January 2020 based on the number of orders placed? [/INST] | SELECT `Sales Channel` FROM `Sales Orders` WHERE OrderDate LIKE '1/%/20' 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: Name the product that was registered in the sales order 'SO - 0005951'. [/INST] | SELECT T FROM ( SELECT DISTINCT CASE WHEN T2.OrderNumber = 'SO - 0005951' THEN T1.`Product Name` ELSE NULL END AS T FROM Products T1 INNER JOIN `Sales Orders` 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: Identify the store location and sales team who processed the sales order 'SO - 0001004'. [/INST] | SELECT T3.`Sales Team`, T1.`City Name` FROM `Store Locations` AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._StoreID = T1.StoreID INNER JOIN `Sales Team` AS T3 ON T3.SalesTeamID = T2._SalesTeamID WHERE T2.OrderNumber = 'SO - 0001004'; |
[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: Identify the top customer of the store located in Gilbert, Arizona based on net profit associated with the customer relationship in 2019. [/INST] | SELECT T1.`Customer Names` FROM Customers AS T1 INNER JOIN `Sales Orders` AS T2 ON T2._CustomerID = T1.CustomerID INNER JOIN `Store Locations` AS T3 ON T3.StoreID = T2._StoreID WHERE T3.`City Name` = 'Gilbert' AND T2.ProcuredDate LIKE '%/%/19' ORDER BY REPLACE(T2.`Unit Price`, ',', '') - REPLACE(T2.`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: How many sales orders were processed by the store located in Chandler in 2020? [/INST] | SELECT SUM(CASE WHEN T2.`City Name` = 'Chandler' AND T1.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 average household income of Glendale? [/INST] | SELECT AVG(`Household Income`) FROM `Store Locations` WHERE `City Name` = 'Glendale'; |
[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 was the best discount applied to sales orders in 2020? [/INST] | SELECT MAX(`Discount Applied`) FROM `Sales Orders` WHERE OrderDate LIKE '%/%/20'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the most consecutive games tied by Ebbsfleet as an away team in the 2008 season? [/INST] | SELECT COUNT(*) FROM matchs WHERE season = 2008 AND AwayTeam = 'Ebbsfleet' AND FTR = 'D'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Of all the divisions in the world, what percentage of them belong to England? [/INST] | SELECT CAST(COUNT(CASE WHEN country = 'England' THEN division ELSE NULL END) AS REAL) * 100 / COUNT(division) FROM divisions; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What percentage of games won, games lost and games drawn does Cittadella have as a home team in total? [/INST] | SELECT CAST(COUNT(CASE WHEN FTR = 'H' THEN 1 ELSE NULL END) / COUNT(HomeTeam) AS REAL) * 100, CAST(COUNT(CASE WHEN FTR = 'A' THEN 1 ELSE NULL END) AS REAL) / COUNT(HomeTeam), CAST(COUNT(CASE WHEN FTR = 'D' THEN 1 ELSE NULL END) AS REAL) / COUNT(HomeTeam) FROM matchs WHERE HomeTeam = 'Cittadella'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Of all the teams that played as a team away against Caen in the 2010 season, which one has the highest winning percentage? [/INST] | SELECT AwayTeam FROM matchs WHERE HomeTeam = 'Caen' AND season = 2010 AND FTR = 'A' GROUP BY AwayTeam ORDER BY COUNT(AwayTeam) DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What percentage of matches played on 2005/07/30 belong to the F1 division? [/INST] | SELECT CAST(SUM(CASE WHEN Div = 'F1' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(Div) FROM matchs WHERE Date = '2005-07-30' ; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What percentage of all tied games did the Sassuolo team play in? [/INST] | SELECT CAST(SUM(CASE WHEN HomeTeam = 'Sassuolo' OR AwayTeam = 'Sassuolo' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(FTR) FROM matchs WHERE FTR = 'D'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the percentage whereby the away team scored 2 goals during the 2017 seasons? [/INST] | SELECT CAST(SUM(CASE WHEN FTAG = 2 THEN 1 ELSE 0 END) / COUNT(FTAG) AS REAL) * 100 FROM matchs WHERE season = 2017; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of all the teams that played in the EFL League One division? [/INST] | SELECT T1.HomeTeam,T1.AwayTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div=T2.division WHERE T2.name = 'EFL League One' and T1.Div = 'E2' ; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many teams playing in divisions in Greece have ever scored 4 or more goals? [/INST] | SELECT COUNT(DISTINCT CASE WHEN T1.FTHG >= 4 THEN HomeTeam ELSE NULL end) + COUNT(DISTINCT CASE WHEN T1.FTAG >= 4 THEN AwayTeam ELSE NULL end) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.country = 'Greece' ; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many matches played in the 2019 season of Scottish Championship league were ended with an equal result of 2-2? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2019 AND T2.name = 'Scottish Championship' AND T1.FTAG = 2 AND T1.FTHG = 2; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which 2 Scottish teams scored 10 goals playing as a local team and in which seasons? [/INST] | SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.country = 'Scotland' AND T1.FTHG = 10; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: From the Spanish LaLiga division in the 2017 season, which team won the most times as a local team and by what percentage? [/INST] | SELECT T1.HomeTeam HWHT , CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(HomeTeam) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga' AND T2.country = 'Spain' AND T1.season = 2017; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many teams that played in the 2012 season belong to any of the English divisions and what percentage play in each of the divisions? [/INST] | SELECT ( SELECT COUNT(T1.Div) AS total FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 ) AS num , CASE WHEN 1 THEN T.result END AS percentage FROM ( SELECT 100.0 * COUNT(T1.Div) / ( SELECT COUNT(T1.Div) FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 ) AS result FROM matchs T1 INNER JOIN divisions T2 ON T2.division = T1.Div WHERE T2.country = 'England' AND T1.season = 2012 GROUP BY T2.division ) AS T; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the highest final-time score across all divisions in the 2021 season? Which team was the team that made up that score? [/INST] | SELECT ( SELECT MAX(MAX(FTAG), MAX(FTHG)) FROM matchs WHERE season = 2021 ) AS T1, AwayTeam FROM matchs WHERE season = 2021 AND FTHG = T1 OR FTAG = T1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the home team in division P1 with the highest final time goal in all seasons? [/INST] | SELECT HomeTeam FROM matchs WHERE Div = 'P1' AND season = 2021 ORDER BY FTHG DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What was the difference in home team and away team win percentages across all divisions in 2010? [/INST] | SELECT CAST(COUNT(CASE WHEN FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(FTR) - CAST(COUNT(CASE WHEN FTR = 'A' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(FTR) DIFFERENCE FROM matchs WHERE season = 2010; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which division had the most draft matches in the 2008 season? [/INST] | SELECT Div FROM matchs WHERE season = 2008 AND FTR = 'D' GROUP BY Div ORDER BY COUNT(FTR) DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team won the match in the EC division on January 20, 2008 at home? [/INST] | SELECT HomeTeam FROM matchs WHERE Div = 'EC' AND Date = '2008-01-20' AND FTR = 'H'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the division in which Club Brugge and Genk competed on September 13, 2009? [/INST] | SELECT T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.Date = '2009-09-13' and T1.HomeTeam = 'Club Brugge' AND T1.AwayTeam = 'Genk'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many matches were played in the Scottish Premiership division from 2006 to 2008? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Scottish Premiership' AND (T1.season BETWEEN 2006 AND 2008); |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: In which division was the match between Hibernian, the away team, and Hearts, the home team, played? To which country does this division belong? [/INST] | SELECT DISTINCT T2.division,T2.country FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.HomeTeam = 'Hearts' AND T1.AwayTeam = 'Hibernian'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which away team in the division of Bundesliga has the highest final time goals? [/INST] | SELECT T1.AwayTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div=T2.division WHERE T2.name = 'Bundesliga' ORDER BY T1.FTAG DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Please provide the names of any three away teams that competed in the Italian divisions. [/INST] | SELECT T1.AwayTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div=T2.division WHERE T2.country = 'Italy' LIMIT 3; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the division that has had the lowest number of draft matches in the 2019 season? [/INST] | SELECT T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2019 AND T1.FTR = 'D' GROUP BY T2.division ORDER BY COUNT(FTR) LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many times did Valencia's home team win in the LaLiga division? [/INST] | SELECT COUNT(T1.HomeTeam) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga' AND T1.HomeTeam = 'Valencia' AND T1.FTR = 'H'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: In how many matches in the Seria A division did both teams have equal goals? [/INST] | SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Seria A' AND T1.FTR = 'D'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many football divisions does England have? [/INST] | SELECT COUNT(division) FROM divisions WHERE country = 'England'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What's the name of the football division in the Netherlands? [/INST] | SELECT name FROM divisions WHERE country = 'Netherlands'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Who is the winner of the game happened on 2009/10/10, between "East Fife" and "Dumbarton"? [/INST] | SELECT CASE WHEN FTR = 'H' THEN 'East Fife' ELSE 'Dumbarton' END WINNER FROM matchs WHERE Date = '2009-10-10' AND HomeTeam = 'East Fife' AND AwayTeam = 'Dumbarton'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What was the final score for the game Bursaspor vs Denizlispor on 2009/4/26? [/INST] | SELECT FTHG, FTAG FROM matchs WHERE Date = '2009-04-26' AND HomeTeam = 'Bursaspor' AND AwayTeam = 'Denizlispor'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: When did the first match that score more than 10 goals happen? [/INST] | SELECT MIN(Date) FROM matchs WHERE FTHG + FTAG > 10; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: For the Ligue 2 game that made the most goals, who is the winner of that game? [/INST] | SELECT CASE WHEN T1.FTR = 'H' THEN T1.HomeTeam ELSE T1.AwayTeam END WINNER FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Ligue 2' ORDER BY T1.FTAG + T1.FTHG DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many Away Victories happened on 2016/3/27 in the LaLiga 2 division? [/INST] | SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'LaLiga 2' AND T1.Date = '2016-03-27' AND T1.FTR = 'A'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many draw games happened on 2018/8/7 for National League? [/INST] | SELECT COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'National League' AND T1.Date = '2018-08-07' AND T1.FTR = 'D'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which country had the game that Away team made the most goals? [/INST] | SELECT T2.country FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division GROUP BY T2.country ORDER BY SUM(T1.FTAG) DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: For a game had a score of 1-8 in the year of 2011, what division was that game in? Give the full name of the division. [/INST] | SELECT T2.division, T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2011 AND T1.FTHG = 1 AND T1.FTAG = 8; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which division had the most games with more than 5 total field goals on 2020/2/22? Give the full name of the division? [/INST] | SELECT T2.division, T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.Date = '2020-02-22' AND T1.FTAG + T1.FTHG > 5 ORDER BY T1.FTAG + T1.FTHG DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the full name of the divison that had the most 0-0 games. [/INST] | SELECT T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.FTAG = 0 AND T1.FTHG = 0 GROUP BY T2.division ORDER BY COUNT(T1.FTAG) DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many Scottish League One games took place on the day that "Pro Vercelli" and "Pescara"had a 5-2 game? [/INST] | SELECT COUNT(T1.Date) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Scottish League One' AND T1.Date = ( SELECT Date FROM matchs WHERE FTHG = 5 AND FTAG = 2 AND HomeTeam = 'Pro Vercelli' AND AwayTeam = 'Pescara' ); |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: List the number of games that ended up with 5-0 in Greece. [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.country = 'Greece' AND T1.FTHG = 5 AND T1.FTAG = 0; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which country did Bradford Team belongs to? [/INST] | SELECT DISTINCT T2.country FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.HomeTeam = 'Bradford' OR T1.AwayTeam = 'Bradford'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many Eredivisie teams have played in 2008? [/INST] | SELECT COUNT(DISTINCT T1.HomeTeam) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Eredivisie' AND T1.season = 2008; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What's the home win ratio of the Bundesliga division in 2021? [/INST] | SELECT CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T2.name = 'Bundesliga'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: For all the games ended up with 1-1, what percentage of them are from Liga NOS division? [/INST] | SELECT CAST(COUNT(CASE WHEN T2.name = 'Liga NOS' THEN T1.Div ELSE NULL END) AS REAL) * 100 / COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.FTHG = 1 AND FTAG = 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many matches were held during the 2021 season's Premier League? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T2.name = 'Premier League'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team was the home team in the match of the Bundesliga division on 2020/10/2? [/INST] | SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.Date = '2020-10-02' AND T2.name = 'Bundesliga'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team won the match of the Bundesliga division on 2020/10/2? [/INST] | SELECT CASE WHEN T1.FTR = 'H' THEN T1.HomeTeam WHEN T1.FTR = 'A' THEN T1.AwayTeam END WINNER FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.Date = '2020-10-02' AND T2.name = 'Bundesliga'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team has the most victories as the home team in matches of the Bundesliga division? [/INST] | SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.FTR = 'H' GROUP BY T1.HomeTeam ORDER BY COUNT(T1.FTR) DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many times did the team Werder Bremen win as the away team in matches of the Bundesliga division? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.AwayTeam = 'Werder Bremen' AND T1.FTR = 'A'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many matches of the Bundesliga division ended with an away victory in the 2021 season? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.FTR = 'A' AND T1.season = 2021; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Of the matches in all seasons of the Bundesliga division, how many of them ended with a tie? [/INST] | SELECT COUNT(T1.Div) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.FTR = 'D'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many home victories does the Bundesliga division have in more or less than the Premier League division in the 2021 season? [/INST] | SELECT COUNT(CASE WHEN T2.name = 'Bundesliga' THEN 1 ELSE NULL END) - COUNT(CASE WHEN T2.name = 'Premier League' THEN 1 ELSE NULL END) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T1.FTR = 'H'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Please list the home teams in the matches of the Bundesliga division that ended with a home victory in the 2021 season. [/INST] | SELECT DISTINCT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T1.FTR = 'H' AND T2.name = 'Bundesliga'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team had more home victories in the 2021 season's matches of the Bundesliga division, Augsburg or Mainz? [/INST] | SELECT CASE WHEN COUNT(CASE WHEN T1.HomeTeam = 'Augsburg' THEN 1 ELSE NULL END) - COUNT(CASE WHEN T1.HomeTeam = ' Mainz' THEN 1 ELSE NULL END) > 0 THEN 'Augsburg' ELSE 'Mainz' END FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T1.FTR = 'H'; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team had the most final-time home-team goals in the 2021 season's matches of the Bundesliga division? [/INST] | SELECT T1.HomeTeam FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.season = 2021 ORDER BY T1.FTHG DESC LIMIT 1; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: How many final-time home-team goals were there in total in all the matches of the Bundesliga division in the 2021 season? [/INST] | SELECT SUM(T1.FTHG) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T2.name = 'Bundesliga' AND T1.season = 2021; |
[INST] Here is a database schema:
divisions :
division [ TEXT ] primary_key
name [ TEXT ]
country [ TEXT ]
matchs :
Div [ TEXT ] matchs.Div = divisions.division
Date [ DATE ]
HomeTeam [ TEXT ]
AwayTeam [ TEXT ]
FTHG [ INTEGER ]
FTAG [ INTEGER ]
FTR [ TEXT ]
season [ INTEGER ]
Please write me a SQL statement that answers the following question: What's the winning rate of Club Brugge in the 2021 Premier League? [/INST] | SELECT CAST(COUNT(CASE WHEN T1.FTR = 'H' THEN 1 ELSE NULL END) + COUNT(CASE WHEN T1.FTR = 'A' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(t1.FTR) FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2021 AND T1.AwayTeam = 'Club Brugge' OR T1.HomeTeam = 'Club Brugge'; |
[INST] Here is a database schema:
awards_players :
playerID [ TEXT ] awards_players.playerID = players.playerID
award [ TEXT ]
year [ INTEGER ]
lgID [ TEXT ]
note [ TEXT ]
pos [ TEXT ]
coaches :
coachID [ TEXT ]
year [ INTEGER ] coaches.year = teams.year
tmID [ TEXT ] coaches.tmID = teams.tmID
lgID [ TEXT ]
stint [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
post_wins [ INTEGER ]
post_losses [ INTEGER ]
draft :
id [ INTEGER ] primary_key
draftYear [ INTEGER ] draft.draftYear = teams.year
draftRound [ INTEGER ]
draftSelection [ INTEGER ]
draftOverall [ INTEGER ]
tmID [ TEXT ] draft.tmID = teams.tmID
firstName [ TEXT ]
lastName [ TEXT ]
suffixName [ TEXT ]
playerID [ TEXT ]
draftFrom [ TEXT ]
lgID [ TEXT ]
player_allstar :
playerID [ TEXT ] player_allstar.playerID = players.playerID
last_name [ TEXT ]
first_name [ TEXT ]
season_id [ INTEGER ]
conference [ TEXT ]
league_id [ TEXT ]
games_played [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
o_rebounds [ INTEGER ]
d_rebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
personal_fouls [ INTEGER ]
fg_attempted [ INTEGER ]
fg_made [ INTEGER ]
ft_attempted [ INTEGER ]
ft_made [ INTEGER ]
three_attempted [ INTEGER ]
three_made [ INTEGER ]
players :
playerID [ TEXT ] primary_key
useFirst [ TEXT ]
firstName [ TEXT ]
middleName [ TEXT ]
lastName [ TEXT ]
nameGiven [ TEXT ]
fullGivenName [ TEXT ]
nameSuffix [ TEXT ]
nameNick [ TEXT ]
pos [ TEXT ]
firstseason [ INTEGER ]
lastseason [ INTEGER ]
height [ REAL ]
weight [ INTEGER ]
college [ TEXT ]
collegeOther [ TEXT ]
birthDate [ DATE ]
birthCity [ TEXT ]
birthState [ TEXT ]
birthCountry [ TEXT ]
highSchool [ TEXT ]
hsCity [ TEXT ]
hsState [ TEXT ]
hsCountry [ TEXT ]
deathDate [ DATE ]
race [ TEXT ]
teams :
year [ INTEGER ]
lgID [ TEXT ]
tmID [ TEXT ]
franchID [ TEXT ]
confID [ TEXT ]
divID [ TEXT ]
rank [ INTEGER ]
confRank [ INTEGER ]
playoff [ TEXT ]
name [ TEXT ]
o_fgm [ INTEGER ]
o_ftm [ INTEGER ]
o_pts [ INTEGER ]
d_pts [ INTEGER ]
homeWon [ INTEGER ]
homeLost [ INTEGER ]
awayWon [ INTEGER ]
awayLost [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
games [ INTEGER ]
arena [ TEXT ]
awards_coaches :
id [ INTEGER ] primary_key
year [ INTEGER ] awards_coaches.year = coaches.year
coachID [ TEXT ] awards_coaches.coachID = coaches.coachID
award [ TEXT ]
lgID [ TEXT ]
note [ TEXT ]
players_teams :
id [ INTEGER ] primary_key
playerID [ TEXT ]
year [ INTEGER ] players_teams.year = teams.year
stint [ INTEGER ]
tmID [ TEXT ] players_teams.tmID = teams.tmID
lgID [ TEXT ]
GP [ INTEGER ]
GS [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
oRebounds [ INTEGER ]
dRebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
PF [ INTEGER ]
fgAttempted [ INTEGER ]
fgMade [ INTEGER ]
ftAttempted [ INTEGER ]
ftMade [ INTEGER ]
threeAttempted [ INTEGER ]
threeMade [ INTEGER ]
PostGP [ INTEGER ]
PostGS [ INTEGER ]
PostMinutes [ INTEGER ]
PostPoints [ INTEGER ]
PostoRebounds [ INTEGER ]
PostdRebounds [ INTEGER ]
PostRebounds [ INTEGER ]
PostAssists [ INTEGER ]
PostSteals [ INTEGER ]
PostBlocks [ INTEGER ]
PostTurnovers [ INTEGER ]
PostPF [ INTEGER ]
PostfgAttempted [ INTEGER ]
PostfgMade [ INTEGER ]
PostftAttempted [ INTEGER ]
PostftMade [ INTEGER ]
PostthreeAttempted [ INTEGER ]
PostthreeMade [ INTEGER ]
note [ TEXT ]
series_post :
id [ INTEGER ] primary_key
year [ INTEGER ] series_post.year = teams.year
round [ TEXT ]
series [ TEXT ]
tmIDWinner [ TEXT ] series_post.tmIDWinner = teams.tmID
lgIDWinner [ TEXT ]
tmIDLoser [ TEXT ] series_post.tmIDLoser = teams.tmID
lgIDLoser [ TEXT ]
W [ INTEGER ]
L [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the winning game from the team, what is the percentage of the winning was home game. [/INST] | SELECT CAST(homeWon AS REAL) * 100 / won FROM teams; |
[INST] Here is a database schema:
awards_players :
playerID [ TEXT ] awards_players.playerID = players.playerID
award [ TEXT ]
year [ INTEGER ]
lgID [ TEXT ]
note [ TEXT ]
pos [ TEXT ]
coaches :
coachID [ TEXT ]
year [ INTEGER ] coaches.year = teams.year
tmID [ TEXT ] coaches.tmID = teams.tmID
lgID [ TEXT ]
stint [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
post_wins [ INTEGER ]
post_losses [ INTEGER ]
draft :
id [ INTEGER ] primary_key
draftYear [ INTEGER ] draft.draftYear = teams.year
draftRound [ INTEGER ]
draftSelection [ INTEGER ]
draftOverall [ INTEGER ]
tmID [ TEXT ] draft.tmID = teams.tmID
firstName [ TEXT ]
lastName [ TEXT ]
suffixName [ TEXT ]
playerID [ TEXT ]
draftFrom [ TEXT ]
lgID [ TEXT ]
player_allstar :
playerID [ TEXT ] player_allstar.playerID = players.playerID
last_name [ TEXT ]
first_name [ TEXT ]
season_id [ INTEGER ]
conference [ TEXT ]
league_id [ TEXT ]
games_played [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
o_rebounds [ INTEGER ]
d_rebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
personal_fouls [ INTEGER ]
fg_attempted [ INTEGER ]
fg_made [ INTEGER ]
ft_attempted [ INTEGER ]
ft_made [ INTEGER ]
three_attempted [ INTEGER ]
three_made [ INTEGER ]
players :
playerID [ TEXT ] primary_key
useFirst [ TEXT ]
firstName [ TEXT ]
middleName [ TEXT ]
lastName [ TEXT ]
nameGiven [ TEXT ]
fullGivenName [ TEXT ]
nameSuffix [ TEXT ]
nameNick [ TEXT ]
pos [ TEXT ]
firstseason [ INTEGER ]
lastseason [ INTEGER ]
height [ REAL ]
weight [ INTEGER ]
college [ TEXT ]
collegeOther [ TEXT ]
birthDate [ DATE ]
birthCity [ TEXT ]
birthState [ TEXT ]
birthCountry [ TEXT ]
highSchool [ TEXT ]
hsCity [ TEXT ]
hsState [ TEXT ]
hsCountry [ TEXT ]
deathDate [ DATE ]
race [ TEXT ]
teams :
year [ INTEGER ]
lgID [ TEXT ]
tmID [ TEXT ]
franchID [ TEXT ]
confID [ TEXT ]
divID [ TEXT ]
rank [ INTEGER ]
confRank [ INTEGER ]
playoff [ TEXT ]
name [ TEXT ]
o_fgm [ INTEGER ]
o_ftm [ INTEGER ]
o_pts [ INTEGER ]
d_pts [ INTEGER ]
homeWon [ INTEGER ]
homeLost [ INTEGER ]
awayWon [ INTEGER ]
awayLost [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
games [ INTEGER ]
arena [ TEXT ]
awards_coaches :
id [ INTEGER ] primary_key
year [ INTEGER ] awards_coaches.year = coaches.year
coachID [ TEXT ] awards_coaches.coachID = coaches.coachID
award [ TEXT ]
lgID [ TEXT ]
note [ TEXT ]
players_teams :
id [ INTEGER ] primary_key
playerID [ TEXT ]
year [ INTEGER ] players_teams.year = teams.year
stint [ INTEGER ]
tmID [ TEXT ] players_teams.tmID = teams.tmID
lgID [ TEXT ]
GP [ INTEGER ]
GS [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
oRebounds [ INTEGER ]
dRebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
PF [ INTEGER ]
fgAttempted [ INTEGER ]
fgMade [ INTEGER ]
ftAttempted [ INTEGER ]
ftMade [ INTEGER ]
threeAttempted [ INTEGER ]
threeMade [ INTEGER ]
PostGP [ INTEGER ]
PostGS [ INTEGER ]
PostMinutes [ INTEGER ]
PostPoints [ INTEGER ]
PostoRebounds [ INTEGER ]
PostdRebounds [ INTEGER ]
PostRebounds [ INTEGER ]
PostAssists [ INTEGER ]
PostSteals [ INTEGER ]
PostBlocks [ INTEGER ]
PostTurnovers [ INTEGER ]
PostPF [ INTEGER ]
PostfgAttempted [ INTEGER ]
PostfgMade [ INTEGER ]
PostftAttempted [ INTEGER ]
PostftMade [ INTEGER ]
PostthreeAttempted [ INTEGER ]
PostthreeMade [ INTEGER ]
note [ TEXT ]
series_post :
id [ INTEGER ] primary_key
year [ INTEGER ] series_post.year = teams.year
round [ TEXT ]
series [ TEXT ]
tmIDWinner [ TEXT ] series_post.tmIDWinner = teams.tmID
lgIDWinner [ TEXT ]
tmIDLoser [ TEXT ] series_post.tmIDLoser = teams.tmID
lgIDLoser [ TEXT ]
W [ INTEGER ]
L [ INTEGER ]
Please write me a SQL statement that answers the following question: Which team(s) has greater than 75% lost among all the games played. [/INST] | SELECT name FROM teams WHERE CAST(lost AS REAL) * 100 / games > 75; |
[INST] Here is a database schema:
awards_players :
playerID [ TEXT ] awards_players.playerID = players.playerID
award [ TEXT ]
year [ INTEGER ]
lgID [ TEXT ]
note [ TEXT ]
pos [ TEXT ]
coaches :
coachID [ TEXT ]
year [ INTEGER ] coaches.year = teams.year
tmID [ TEXT ] coaches.tmID = teams.tmID
lgID [ TEXT ]
stint [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
post_wins [ INTEGER ]
post_losses [ INTEGER ]
draft :
id [ INTEGER ] primary_key
draftYear [ INTEGER ] draft.draftYear = teams.year
draftRound [ INTEGER ]
draftSelection [ INTEGER ]
draftOverall [ INTEGER ]
tmID [ TEXT ] draft.tmID = teams.tmID
firstName [ TEXT ]
lastName [ TEXT ]
suffixName [ TEXT ]
playerID [ TEXT ]
draftFrom [ TEXT ]
lgID [ TEXT ]
player_allstar :
playerID [ TEXT ] player_allstar.playerID = players.playerID
last_name [ TEXT ]
first_name [ TEXT ]
season_id [ INTEGER ]
conference [ TEXT ]
league_id [ TEXT ]
games_played [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
o_rebounds [ INTEGER ]
d_rebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
personal_fouls [ INTEGER ]
fg_attempted [ INTEGER ]
fg_made [ INTEGER ]
ft_attempted [ INTEGER ]
ft_made [ INTEGER ]
three_attempted [ INTEGER ]
three_made [ INTEGER ]
players :
playerID [ TEXT ] primary_key
useFirst [ TEXT ]
firstName [ TEXT ]
middleName [ TEXT ]
lastName [ TEXT ]
nameGiven [ TEXT ]
fullGivenName [ TEXT ]
nameSuffix [ TEXT ]
nameNick [ TEXT ]
pos [ TEXT ]
firstseason [ INTEGER ]
lastseason [ INTEGER ]
height [ REAL ]
weight [ INTEGER ]
college [ TEXT ]
collegeOther [ TEXT ]
birthDate [ DATE ]
birthCity [ TEXT ]
birthState [ TEXT ]
birthCountry [ TEXT ]
highSchool [ TEXT ]
hsCity [ TEXT ]
hsState [ TEXT ]
hsCountry [ TEXT ]
deathDate [ DATE ]
race [ TEXT ]
teams :
year [ INTEGER ]
lgID [ TEXT ]
tmID [ TEXT ]
franchID [ TEXT ]
confID [ TEXT ]
divID [ TEXT ]
rank [ INTEGER ]
confRank [ INTEGER ]
playoff [ TEXT ]
name [ TEXT ]
o_fgm [ INTEGER ]
o_ftm [ INTEGER ]
o_pts [ INTEGER ]
d_pts [ INTEGER ]
homeWon [ INTEGER ]
homeLost [ INTEGER ]
awayWon [ INTEGER ]
awayLost [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
games [ INTEGER ]
arena [ TEXT ]
awards_coaches :
id [ INTEGER ] primary_key
year [ INTEGER ] awards_coaches.year = coaches.year
coachID [ TEXT ] awards_coaches.coachID = coaches.coachID
award [ TEXT ]
lgID [ TEXT ]
note [ TEXT ]
players_teams :
id [ INTEGER ] primary_key
playerID [ TEXT ]
year [ INTEGER ] players_teams.year = teams.year
stint [ INTEGER ]
tmID [ TEXT ] players_teams.tmID = teams.tmID
lgID [ TEXT ]
GP [ INTEGER ]
GS [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
oRebounds [ INTEGER ]
dRebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
PF [ INTEGER ]
fgAttempted [ INTEGER ]
fgMade [ INTEGER ]
ftAttempted [ INTEGER ]
ftMade [ INTEGER ]
threeAttempted [ INTEGER ]
threeMade [ INTEGER ]
PostGP [ INTEGER ]
PostGS [ INTEGER ]
PostMinutes [ INTEGER ]
PostPoints [ INTEGER ]
PostoRebounds [ INTEGER ]
PostdRebounds [ INTEGER ]
PostRebounds [ INTEGER ]
PostAssists [ INTEGER ]
PostSteals [ INTEGER ]
PostBlocks [ INTEGER ]
PostTurnovers [ INTEGER ]
PostPF [ INTEGER ]
PostfgAttempted [ INTEGER ]
PostfgMade [ INTEGER ]
PostftAttempted [ INTEGER ]
PostftMade [ INTEGER ]
PostthreeAttempted [ INTEGER ]
PostthreeMade [ INTEGER ]
note [ TEXT ]
series_post :
id [ INTEGER ] primary_key
year [ INTEGER ] series_post.year = teams.year
round [ TEXT ]
series [ TEXT ]
tmIDWinner [ TEXT ] series_post.tmIDWinner = teams.tmID
lgIDWinner [ TEXT ]
tmIDLoser [ TEXT ] series_post.tmIDLoser = teams.tmID
lgIDLoser [ TEXT ]
W [ INTEGER ]
L [ INTEGER ]
Please write me a SQL statement that answers the following question: List the team name and the total wins of the team in year 2005 which has greater winning from the previous year. [/INST] | SELECT T1.name, T1.won FROM teams AS T1 INNER JOIN ( SELECT * FROM teams WHERE year = 2004 ) AS T2 on T1.tmID = T2.tmID WHERE T1.year = 2005 and T1.won > T2.won; |
[INST] Here is a database schema:
awards_players :
playerID [ TEXT ] awards_players.playerID = players.playerID
award [ TEXT ]
year [ INTEGER ]
lgID [ TEXT ]
note [ TEXT ]
pos [ TEXT ]
coaches :
coachID [ TEXT ]
year [ INTEGER ] coaches.year = teams.year
tmID [ TEXT ] coaches.tmID = teams.tmID
lgID [ TEXT ]
stint [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
post_wins [ INTEGER ]
post_losses [ INTEGER ]
draft :
id [ INTEGER ] primary_key
draftYear [ INTEGER ] draft.draftYear = teams.year
draftRound [ INTEGER ]
draftSelection [ INTEGER ]
draftOverall [ INTEGER ]
tmID [ TEXT ] draft.tmID = teams.tmID
firstName [ TEXT ]
lastName [ TEXT ]
suffixName [ TEXT ]
playerID [ TEXT ]
draftFrom [ TEXT ]
lgID [ TEXT ]
player_allstar :
playerID [ TEXT ] player_allstar.playerID = players.playerID
last_name [ TEXT ]
first_name [ TEXT ]
season_id [ INTEGER ]
conference [ TEXT ]
league_id [ TEXT ]
games_played [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
o_rebounds [ INTEGER ]
d_rebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
personal_fouls [ INTEGER ]
fg_attempted [ INTEGER ]
fg_made [ INTEGER ]
ft_attempted [ INTEGER ]
ft_made [ INTEGER ]
three_attempted [ INTEGER ]
three_made [ INTEGER ]
players :
playerID [ TEXT ] primary_key
useFirst [ TEXT ]
firstName [ TEXT ]
middleName [ TEXT ]
lastName [ TEXT ]
nameGiven [ TEXT ]
fullGivenName [ TEXT ]
nameSuffix [ TEXT ]
nameNick [ TEXT ]
pos [ TEXT ]
firstseason [ INTEGER ]
lastseason [ INTEGER ]
height [ REAL ]
weight [ INTEGER ]
college [ TEXT ]
collegeOther [ TEXT ]
birthDate [ DATE ]
birthCity [ TEXT ]
birthState [ TEXT ]
birthCountry [ TEXT ]
highSchool [ TEXT ]
hsCity [ TEXT ]
hsState [ TEXT ]
hsCountry [ TEXT ]
deathDate [ DATE ]
race [ TEXT ]
teams :
year [ INTEGER ]
lgID [ TEXT ]
tmID [ TEXT ]
franchID [ TEXT ]
confID [ TEXT ]
divID [ TEXT ]
rank [ INTEGER ]
confRank [ INTEGER ]
playoff [ TEXT ]
name [ TEXT ]
o_fgm [ INTEGER ]
o_ftm [ INTEGER ]
o_pts [ INTEGER ]
d_pts [ INTEGER ]
homeWon [ INTEGER ]
homeLost [ INTEGER ]
awayWon [ INTEGER ]
awayLost [ INTEGER ]
won [ INTEGER ]
lost [ INTEGER ]
games [ INTEGER ]
arena [ TEXT ]
awards_coaches :
id [ INTEGER ] primary_key
year [ INTEGER ] awards_coaches.year = coaches.year
coachID [ TEXT ] awards_coaches.coachID = coaches.coachID
award [ TEXT ]
lgID [ TEXT ]
note [ TEXT ]
players_teams :
id [ INTEGER ] primary_key
playerID [ TEXT ]
year [ INTEGER ] players_teams.year = teams.year
stint [ INTEGER ]
tmID [ TEXT ] players_teams.tmID = teams.tmID
lgID [ TEXT ]
GP [ INTEGER ]
GS [ INTEGER ]
minutes [ INTEGER ]
points [ INTEGER ]
oRebounds [ INTEGER ]
dRebounds [ INTEGER ]
rebounds [ INTEGER ]
assists [ INTEGER ]
steals [ INTEGER ]
blocks [ INTEGER ]
turnovers [ INTEGER ]
PF [ INTEGER ]
fgAttempted [ INTEGER ]
fgMade [ INTEGER ]
ftAttempted [ INTEGER ]
ftMade [ INTEGER ]
threeAttempted [ INTEGER ]
threeMade [ INTEGER ]
PostGP [ INTEGER ]
PostGS [ INTEGER ]
PostMinutes [ INTEGER ]
PostPoints [ INTEGER ]
PostoRebounds [ INTEGER ]
PostdRebounds [ INTEGER ]
PostRebounds [ INTEGER ]
PostAssists [ INTEGER ]
PostSteals [ INTEGER ]
PostBlocks [ INTEGER ]
PostTurnovers [ INTEGER ]
PostPF [ INTEGER ]
PostfgAttempted [ INTEGER ]
PostfgMade [ INTEGER ]
PostftAttempted [ INTEGER ]
PostftMade [ INTEGER ]
PostthreeAttempted [ INTEGER ]
PostthreeMade [ INTEGER ]
note [ TEXT ]
series_post :
id [ INTEGER ] primary_key
year [ INTEGER ] series_post.year = teams.year
round [ TEXT ]
series [ TEXT ]
tmIDWinner [ TEXT ] series_post.tmIDWinner = teams.tmID
lgIDWinner [ TEXT ]
tmIDLoser [ TEXT ] series_post.tmIDLoser = teams.tmID
lgIDLoser [ TEXT ]
W [ INTEGER ]
L [ INTEGER ]
Please write me a SQL statement that answers the following question: For team who has more home won than home lost more than 80%, list the team name and the offense points. [/INST] | SELECT name, o_pts FROM teams WHERE CAST((homeWon - homeLost) AS REAL) * 100 / games > 80; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.