input stringlengths 122 2.7k | output stringlengths 24 805 |
|---|---|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: How many employees have Andrew Fuller as their direct supervisor? [/INST] [/INST] | SELECT COUNT(EmployeeID) FROM Employees WHERE ReportsTo = ( SELECT EmployeeID FROM Employees WHERE LastName = 'Fuller' AND FirstName = 'Andrew' ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Which employee has the highest salary? Please give his or her full name. [/INST] [/... | SELECT FirstName, LastName FROM Employees WHERE Salary = ( SELECT MAX(Salary) FROM Employees ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: How much higher is the salary of Andrew Fuller than that of Nancy Davolio? [/INST] ... | SELECT ( SELECT Salary FROM Employees WHERE LastName = 'Fuller' AND FirstName = 'Andrew' ) - ( SELECT Salary FROM Employees WHERE LastName = 'Davolio' AND FirstName = 'Nancy' ) AS RESULT; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Among the employees working as Sales Representatives, how many of them are located ... | SELECT COUNT(Country) FROM Employees WHERE Title = 'Sales Representative' AND Country = 'UK'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Which employee is in charge of the sales in Hollis? Please give the employee's full... | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Hollis'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: The sales of how many territories is Nancy Davolio in charge of? [/INST] [/INST] | SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Nancy' AND T1.LastName = 'Davolio'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the names of all the territories whose sales are taken in charge by Nan... | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.FirstName = 'Nancy' AND T1.LastName = 'Davolio'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: The sales of how many territories in total do the employees in London take charge o... | SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.City = 'London'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the territories whose sales are taken in charge by the employees who re... | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.ReportsTo = ( SELECT EmployeeID FROM Employees WHERE FirstName = 'Andrew' AND LastName = 'Fuller' ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: How many employees in the UK takes charge of the sales in over 4 territories? [/INS... | SELECT COUNT(COUNTEID) FROM ( SELECT T1.EmployeeID AS COUNTEID FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.Country = 'UK' GROUP BY T1.EmployeeID HAVING COUNT(T2.TerritoryID) > 4 ) T1; |
[INST] Please write me a SQL statement that answers the following question: How many territories are there in the Eastern Region? [/INST] [/INST] | SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern'; |
[INST] Please write me a SQL statement that answers the following question: Please list all the territories in the Eastern Region. [/INST] [/INST] | SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern'; |
[INST] Please write me a SQL statement that answers the following question: How many employees in total are in charge of the sales in the Eastern Region? [/INST] [/INST] | SELECT COUNT(T.EmployeeID) FROM ( SELECT T3.EmployeeID FROM Region AS T1 INNER JOIN Territories AS T2 ON T1.RegionID = T2.RegionID INNER JOIN EmployeeTerritories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.RegionDescription = 'Eastern' GROUP BY T3.EmployeeID ) T; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the home phone numbers of the employees who are in charge of the sales ... | SELECT T1.HomePhone FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID INNER JOIN Region AS T4 ON T3.RegionID = T4.RegionID WHERE T4.RegionDescription = 'Eastern ' GROUP BY T1.HomePhone; |
[INST] Please write me a SQL statement that answers the following question: How many more territories are there in than Eastern Region than in the Southern Region? [/INST] [/INST] | SELECT ( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' ) - ( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Southern' ) AS Calu; |
[INST] Please write me a SQL statement that answers the following question: Please list the names of all the products ordered in order no. 10248. [/INST] [/INST] | SELECT T1.ProductName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10248; |
[INST] Please write me a SQL statement that answers the following question: What is the quantity of Ikura ordered in order no. 10273? [/INST] [/INST] | SELECT T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10273 AND T1.ProductName = 'Ikura'; |
[INST] Please write me a SQL statement that answers the following question: What is the total price of Ikura ordered in order no. 10273? [/INST] [/INST] | SELECT T2.UnitPrice * T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10273 AND T1.ProductName = 'Ikura'; |
[INST] Please write me a SQL statement that answers the following question: What is the total production of the product that is ordered in the highest quantity in order no. 10248? [/INST] [/INST] | SELECT T1.UnitsInStock + T1.UnitsOnOrder FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10248 ORDER BY T2.Quantity DESC LIMIT 1; |
[INST] Please write me a SQL statement that answers the following question: Of all the products ordered in order no. 10248, which product has the highest user satisfaction? [/INST] [/INST] | SELECT T1.ProductName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10248 ORDER BY T1.ReorderLevel DESC LIMIT 1; |
[INST] Please write me a SQL statement that answers the following question: How many orders have asked for the product Tofu? [/INST] [/INST] | SELECT COUNT(T2.OrderID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Tofu'; |
[INST] Please write me a SQL statement that answers the following question: Please list the IDs of the orders with a product whose production is not continuous. [/INST] [/INST] | SELECT T2.OrderID FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Discontinued = 1; |
[INST] Please write me a SQL statement that answers the following question: Of all the orders that have ordered Ikura, how many of them enjoys a unit price that's lower than its standard unit price? [/INST] [/INST] | SELECT COUNT(T2.OrderID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Ikura' AND T2.UnitPrice < T1.UnitPrice; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Aniseed Syrup'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Japan'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT DISTINCT T2.Phone FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitsInStock < T1.UnitsOnOrder; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'USA' AND T1.Discontinued = 1; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitPrice = ( SELECT MAX(UnitPrice) FROM Products ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average salary of the employees who takes charge of the sales of over 4... | SELECT AVG(T1.Salary) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.EmployeeID HAVING COUNT(T2.TerritoryID) > 4; |
[INST] Please write me a SQL statement that answers the following question: How much lower in percentage is the unit price of Ikura in order no. 10273 than its standard unit price? [/INST] [/INST] | SELECT CAST((T1.UnitPrice - T2.UnitPrice) AS REAL) * 100 / T1.UnitPrice FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10273 AND T1.ProductName = 'Ikura'; |
[INST] Please write me a SQL statement that answers the following question: What is the average quantity of Ikura ordered in one order? [/INST] [/INST] | SELECT CAST(SUM(T2.Quantity) AS REAL) / COUNT(T2.OrderID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Ikura'; |
[INST] Please write me a SQL statement that answers the following question: Among the products ordered in order no. 10248, which product has the biggest ratio of units on order to units in stock? [/INST] [/INST] | SELECT T1.ProductName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10248 ORDER BY T1.UnitsOnOrder / T1.UnitsInStock DESC LIMIT 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Give the full name of the youngest employee. [/INST] [/INST] | SELECT FirstName, LastName FROM Employees WHERE BirthDate = ( SELECT MAX(BirthDate) FROM Employees ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Who is the newest hired employee? Give the full name. [/INST] [/INST] | SELECT FirstName, LastName FROM Employees WHERE HireDate = ( SELECT MAX(HireDate) FROM Employees ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Emplo... | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Michael' AND T1.LastName = 'Suyama'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Give the name of the territory where Mr. Robert King works. [/INST] [/INST] | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.TitleOfCourtesy = 'Mr.' AND T1.FirstName = 'Robert' AND T1.LastName = 'King'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Which territory does Ms. Laura Callahan's direct supervisor work in? Give the name ... | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.EmployeeID = ( SELECT ReportsTo FROM Employees WHERE TitleOfCourtesy = 'Ms.' AND FirstName = 'Laura' AND LastName = 'Callahan... |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Who is in charge of the "Santa Monica" territory? Give the full name. [/INST] [/INS... | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Santa Monica'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Give the home phone number of the employee who is in charge of "Savannah" territory... | SELECT T1.HomePhone FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Savannah'; |
[INST] Please write me a SQL statement that answers the following question: For the order from "HILAA" on 1997/12/25, what was the total quantity of the products in that order? [/INST] [/INST] | SELECT SUM(T2.Quantity) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID WHERE T1.CustomerID = 'HILAA' AND T1.OrderDate LIKE '1997-12-25%'; |
[INST] Please write me a SQL statement that answers the following question: For the order paying the highest freight, how many kinds of products does it contain? [/INST] [/INST] | SELECT COUNT(T2.ProductID) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID WHERE T1.Freight = ( SELECT MAX(Freight) FROM Orders ) GROUP BY T1.OrderID; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10585; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping'; |
[INST] Here is a database schema:
Categories :
CategoryID [ INTEGER ] primary_key
CategoryName [ TEXT ]
Description [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.Categor... | SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Dairy Products'; |
[INST] Here is a database schema:
Categories :
CategoryID [ INTEGER ] primary_key
CategoryName [ TEXT ]
Description [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.Categor... | SELECT T2.CategoryName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.ProductName = 'Tofu'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT SUM(T1.UnitsInStock + T1.UnitsOnOrder) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Escargots Nouveaux'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T1.ReorderLevel FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Nord-Ost-Fisch Handelsgesellschaft mbH'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Karkki Oy'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Gudbrandsdalsost'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.Country FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Scottish Longbreads'; |
[INST] Please write me a SQL statement that answers the following question: Give the number of territories in the "Northern" region. [/INST] [/INST] | SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Northern'; |
[INST] Please write me a SQL statement that answers the following question: Which region is "Columbia" in? [/INST] [/INST] | SELECT T2.RegionDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T1.TerritoryDescription = 'Columbia'; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT CAST(COUNT(CASE WHEN T2.CompanyName = 'United Package' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.CustomerID = 'WHITC'; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT CAST((COUNT(CASE WHEN T2.CompanyName = 'United Package' THEN 1 ELSE NULL END) - COUNT(CASE WHEN T2.CompanyName = 'Speedy Express' THEN 1 ELSE NULL END)) AS REAL) * 100 / COUNT(CASE WHEN T2.CompanyName = 'Speedy Express' THEN 1 ELSE NULL END) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperI... |
[INST] Please write me a SQL statement that answers the following question: How many times is the number of territories in "Eastern Region" than "Southern Region"? [/INST] [/INST] | SELECT CAST(( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' ) AS REAL) / ( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Southern' ) ... |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
CustomerName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Please write me a SQL statement that answers the following question: How many customers are there in the country with the highe... | SELECT COUNT(CustomerID) FROM Customers GROUP BY Country ORDER BY COUNT(CustomerID) DESC LIMIT 1; |
[INST] Here is a database schema:
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID
Please write me a SQL statement t... | SELECT OrderID FROM Orders WHERE Freight > 800; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
CustomerName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Please write me a SQL statement that answers the following question: What is the Island Trading customer's complete address? [/... | SELECT Address, City, Region, Country, PostalCode FROM Customers WHERE CompanyName = 'Island Trading'; |
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID
Unit [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the followin... | SELECT ProductName FROM Products WHERE UnitPrice = ( SELECT MAX(UnitPrice) FROM Products ); |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Please write me a SQL statement that answers the following question: How many suppliers are there in the United ... | SELECT COUNT(SupplierID) FROM Suppliers WHERE Country = 'USA'; |
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID
Unit [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the followin... | SELECT ProductName FROM Products WHERE ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the full name of the employee with the highest salary? [/INST] [/INST] | SELECT FirstName, LastName FROM Employees WHERE Salary = ( SELECT MAX(Salary) FROM Employees ); |
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID
Unit [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the followin... | SELECT ProductName FROM Products WHERE Discontinued = 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average salary of sales representatives in the United Kingdom? [/INST] ... | SELECT AVG(Salary) FROM Employees WHERE Title = 'Sales Representative' AND Country = 'UK'; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.ShipCountry = 'USA' GROUP BY T2.CompanyName ORDER BY COUNT(T2.CompanyName) DESC LIMIT 1; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT COUNT(T1.ProductName) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Pavlova, Ltd.'; |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.CustomerID = 'GREAL' AND T2.CompanyName = 'United Package'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products ); |
[INST] Here is a database schema:
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Employees.EmployeeID
OrderDate [ DATETIME ]
ShipperID [ I... | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'United Package'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1 AND T2.Country = 'Australia'; |
[INST] Please write me a SQL statement that answers the following question: How much is the total purchase price, including freight, of the top 2 most expensive products? [/INST] [/INST] | SELECT T2.UnitPrice * T2.Quantity + T1.Freight FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID ORDER BY T2.UnitPrice * T2.Quantity + T1.Freight DESC LIMIT 2; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T1.SupplierID FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID GROUP BY T1.SupplierID ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Please write me a SQL statement that answers the following question: What are the names of the products that were ordered that have a unit price of no more than 5? [/INST] [/INST] | SELECT DISTINCT T1.ProductName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.UnitPrice < 5; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the title of the employee with the highest number of territories in charge?... | SELECT T1.Title FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.Title ORDER BY COUNT(T2.TerritoryID) DESC LIMIT 1; |
[INST] Please write me a SQL statement that answers the following question: What is the most ordered products by customers? [/INST] [/INST] | SELECT T1.ProductID FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Which territories is the employee with a doctorate in charge of? List all of the te... | SELECT T3.TerritoryDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T1.TitleOfCourtesy = 'Dr.'; |
[INST] Please write me a SQL statement that answers the following question: What are the territory descriptions of territories in the Eastern region? [/INST] [/INST] | SELECT DISTINCT T1.TerritoryDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Eastern' ORDER BY T1.TerritoryDescription; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the average number of territories do each sales representative is in charge... | SELECT CAST(COUNT(T2.TerritoryID) AS REAL) / COUNT(DISTINCT T1.EmployeeID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.Title = 'Sales Representative'; |
[INST] Here is a database schema:
Categories :
CategoryID [ INTEGER ] primary_key
CategoryName [ TEXT ]
Description [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.Categor... | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Beverages' ORDER BY T1.ReorderLevel DESC LIMIT 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Emplo... | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.FirstName, T1.LastName ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Please write me a SQL statement that answers the following question: How many products were ordered in the order with the highest freight? [/INST] [/INST] | SELECT COUNT(T2.ProductID) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID GROUP BY T2.ProductID ORDER BY COUNT(T1.Freight) DESC LIMIT 1; |
[INST] Here is a database schema:
Categories :
CategoryID [ INTEGER ] primary_key
CategoryName [ TEXT ]
Description [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.Categor... | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.CategoryName = 'Seafood' ORDER BY T1.UnitsInStock + T1.UnitsOnOrder DESC LIMIT 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: What is the difference in salary of the top 2 employees with the highest number of ... | SELECT MAX(Salary) - MIN(Salary) FROM ( SELECT T1.Salary FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.EmployeeID, T1.Salary ORDER BY COUNT(T2.TerritoryID) DESC LIMIT 2 ) T1; |
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Suppliers.SupplierID
CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID
Unit [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the followin... | SELECT SUM(UnitPrice) / COUNT(UnitPrice) FROM Products WHERE UnitsInStock > 50; |
[INST] Please write me a SQL statement that answers the following question: List the company names of customers from the city with the most customers. [/INST] [/INST] | SELECT CompanyName FROM `Customer and Suppliers by City` WHERE CITY = ( SELECT City FROM `Customer and Suppliers by City` GROUP BY City ORDER BY COUNT(Relationship) DESC LIMIT 1 ); |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
CustomerName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Please write me a SQL statement that answers the following question: Find and list the company name, company contact name, and ... | SELECT CompanyName, ContactName, ContactTitle FROM Customers WHERE City = 'Madrid'; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Give the full name and contact number of employees in descending order of age. [/IN... | SELECT FirstName, LastName, HomePhone FROM Employees ORDER BY BirthDate DESC; |
[INST] Please write me a SQL statement that answers the following question: Calculate the average price of products shipped to the UK. [/INST] [/INST] | SELECT AVG(UnitPrice) AS avg FROM Invoices WHERE Country = 'UK'; |
[INST] Please write me a SQL statement that answers the following question: Among all the orders, which products sold for the most amount? [/INST] [/INST] | SELECT ProductID FROM `Order Details` GROUP BY ProductID ORDER BY SUM(Quantity) DESC LIMIT 1; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.CompanyName, T2.Address, T2.Phone FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitPrice > 30; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
CustomerName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] ... | SELECT DISTINCT T1.CompanyName, T1.Address FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Freight > ( SELECT AVG(Freight) FROM Orders ); |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Find and list the full name of employees who are from the territory, Wilton. [/INST... | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID WHERE T3.TerritoryDescription = 'Wilton'; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1 AND T2.Country != 'USA'; |
[INST] Please write me a SQL statement that answers the following question: List the top five most costly products in 1998. [/INST] [/INST] | SELECT T3.ProductName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.OrderDate LIKE '1998%' ORDER BY T3.UnitPrice + T1.Freight DESC LIMIT 5; |
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
CustomerName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Shippers :
ShipperID [ INTEGER ] primary_key
ShipperName [ TEXT ]
Phone [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
Custom... | SELECT COUNT(T3.CustomerID) FROM Shippers AS T1 INNER JOIN Orders AS T2 ON T1.ShipperID = T2.ShipVia INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T2.ShipName = 'Federal Shipping'; |
[INST] Please write me a SQL statement that answers the following question: List the name of the top ten most ordered product's names in descending order of the number of orders. [/INST] [/INST] | SELECT T3.ProductName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID GROUP BY T3.ProductName ORDER BY COUNT(*) DESC LIMIT 10; |
[INST] Here is a database schema:
Suppliers :
SupplierID [ INTEGER ] primary_key
SupplierName [ TEXT ]
ContactName [ TEXT ]
Address [ TEXT ]
City [ TEXT ]
PostalCode [ TEXT ]
Country [ TEXT ]
Phone [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
ProductName [ TEXT ]
SupplierID [ INTEGER ] Products.SupplierID = Su... | SELECT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID GROUP BY T2.SupplierID, T2.CompanyName ORDER BY COUNT(T1.ProductName) DESC LIMIT 1; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Please write me a SQL statement that answers the following question: Please list the full name and region of each employee in alphabetical order. [/INST... | SELECT DISTINCT T1.FirstName, T1.LastName, T4.RegionDescription FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Territories AS T3 ON T2.TerritoryID = T3.TerritoryID INNER JOIN Region AS T4 ON T3.RegionID = T4.RegionID ORDER BY T1.FirstName; |
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
LastName [ TEXT ]
FirstName [ TEXT ]
BirthDate [ DATE ]
Photo [ TEXT ]
Notes [ TEXT ]
Orders :
OrderID [ INTEGER ] primary_key
CustomerID [ INTEGER ] Orders.CustomerID = Customers.CustomerID
EmployeeID [ INTEGER ] Orders.EmployeeID = Emplo... | SELECT FirstName, LastName, Title, address FROM Employees WHERE EmployeeID = ( SELECT T1.EmployeeID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderDate BETWEEN '1996-01-01 00:00:00' AND '1997-01-01 00:00:00' GROUP BY T1.EmployeeID ORDER BY COUNT(T2.OrderID) DESC LIMIT 1 ); |
[INST] Please write me a SQL statement that answers the following question: What was the average unit price of products shipped via United Package in 1997? [/INST] [/INST] | SELECT AVG(T2.UnitPrice) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Shippers AS T3 ON T1.ShipVia = T3.ShipperID WHERE T1.OrderDate LIKE '1997%' AND T3.CompanyName = 'United Package'; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.