input
stringlengths 193
2.69k
| output
stringlengths 24
744
|
|---|---|
[INST] Here is a database schema:
rootbeerbrand :
BrandID [ INTEGER ] primary_key
BrandName [ TEXT ]
FirstBrewedYear [ INTEGER ]
BreweryName [ TEXT ]
City [ TEXT ]
State [ TEXT ]
Country [ TEXT ]
Description [ TEXT ]
CaneSugar [ TEXT ]
CornSyrup [ TEXT ]
Honey [ TEXT ]
ArtificialSweetener [ TEXT ]
Caffeinated [ TEXT ]
Alcoholic [ TEXT ]
AvailableInCans [ TEXT ]
AvailableInBottles [ TEXT ]
AvailableInKegs [ TEXT ]
Website [ TEXT ]
FacebookPage [ TEXT ]
Twitter [ TEXT ]
WholesaleCost [ REAL ]
CurrentRetailPrice [ REAL ]
rootbeerreview :
CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID
BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID
StarRating [ INTEGER ]
ReviewDate [ DATE ]
Review [ TEXT ]
Please write me a SQL statement that answers the following question: Which brand in 2012 has the lowest star rating and contains cane sugar as well as honey? [/INST]
|
SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T1.CaneSugar = 'TRUE' AND T1.Honey = 'TRUE' AND T2.StarRating = 1 AND T2.ReviewDate LIKE '2012%';
|
[INST] Here is a database schema:
location :
LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID
LocationName [ TEXT ]
StreetAddress [ TEXT ]
City [ TEXT ]
State [ TEXT ]
ZipCode [ INTEGER ]
rootbeer :
RootBeerID [ INTEGER ] primary_key
BrandID [ INTEGER ] rootbeer.BrandID = rootbeerbrand.BrandID
ContainerType [ TEXT ]
LocationID [ INTEGER ] rootbeer.LocationID = geolocation.LocationID
PurchaseDate [ DATE ]
Please write me a SQL statement that answers the following question: Which location sold more bottles of beer? [/INST]
|
SELECT T2.LocationName FROM rootbeer AS T1 INNER JOIN location AS T2 ON T1.LocationID = T2.LocationID WHERE T1.ContainerType = 'Bottle' GROUP BY T2.LocationID ORDER BY COUNT(T1.LocationID) DESC LIMIT 1;
|
[INST] Here is a database schema:
rootbeerbrand :
BrandID [ INTEGER ] primary_key
BrandName [ TEXT ]
FirstBrewedYear [ INTEGER ]
BreweryName [ TEXT ]
City [ TEXT ]
State [ TEXT ]
Country [ TEXT ]
Description [ TEXT ]
CaneSugar [ TEXT ]
CornSyrup [ TEXT ]
Honey [ TEXT ]
ArtificialSweetener [ TEXT ]
Caffeinated [ TEXT ]
Alcoholic [ TEXT ]
AvailableInCans [ TEXT ]
AvailableInBottles [ TEXT ]
AvailableInKegs [ TEXT ]
Website [ TEXT ]
FacebookPage [ TEXT ]
Twitter [ TEXT ]
WholesaleCost [ REAL ]
CurrentRetailPrice [ REAL ]
rootbeerreview :
CustomerID [ INTEGER ] rootbeerreview.CustomerID = customers.CustomerID
BrandID [ INTEGER ] rootbeerreview.BrandID = rootbeerbrand.BrandID
StarRating [ INTEGER ]
ReviewDate [ DATE ]
Review [ TEXT ]
Please write me a SQL statement that answers the following question: Please name any three root beer brands that have the highest market evaluation and acceptance. [/INST]
|
SELECT DISTINCT T1.BrandName FROM rootbeerbrand AS T1 INNER JOIN rootbeerreview AS T2 ON T1.BrandID = T2.BrandID WHERE T2.StarRating = 5 LIMIT 3;
|
[INST] Here is a database schema:
geolocation :
LocationID [ INTEGER ] primary_key geolocation.LocationID = location.LocationID
Latitude [ REAL ]
Longitude [ REAL ]
location :
LocationID [ INTEGER ] primary_key location.LocationID = geolocation.LocationID
LocationName [ TEXT ]
StreetAddress [ TEXT ]
City [ TEXT ]
State [ TEXT ]
ZipCode [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the precise location of the Sac State American River Courtyard? [/INST]
|
SELECT T2.Latitude, T2.Longitude FROM location AS T1 INNER JOIN geolocation AS T2 ON T1.LocationID = T2.LocationID WHERE T1.LocationName = 'Sac State American River Courtyard';
|
[INST] Here is a database schema:
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many sales ids are there for customer id 80? [/INST]
|
SELECT COUNT(SalesID) FROM Sales WHERE CustomerID = 80;
|
[INST] Here is a database schema:
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Count the total quantity for sales from id 1 to 10. [/INST]
|
SELECT SUM(Quantity) FROM Sales WHERE SalesID BETWEEN 1 AND 10;
|
[INST] Here is a database schema:
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the average quantity per sales from sales id 20 to 30. [/INST]
|
SELECT AVG(Quantity) FROM Sales WHERE SalesID BETWEEN 20 AND 30;
|
[INST] Here is a database schema:
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List down the product id for products with the highest quantity. [/INST]
|
SELECT DISTINCT ProductID FROM Sales WHERE Quantity = ( SELECT MAX(Quantity) FROM Sales );
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: How many product ids have the lowest price? [/INST]
|
SELECT COUNT(DISTINCT ProductID) FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products );
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: List down product names of free gifts. [/INST]
|
SELECT Name FROM Products WHERE Price = 0;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: List down the product name for products from id 1 to 10. [/INST]
|
SELECT Name FROM Products WHERE ProductID BETWEEN 1 AND 10;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the product with the lowest quantity? [/INST]
|
SELECT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.Quantity LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many customer ids have purchased Hex Nut 9? [/INST]
|
SELECT COUNT(T1.CustomerID) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 9';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total sales ids that were sales of Flat Washer 8. [/INST]
|
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Flat Washer 8';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List down all of the product names that were placed by sales person with id 10. [/INST]
|
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesPersonID = 10;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List down the first name of customers who placed order for product id 1. [/INST]
|
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T2.ProductID = 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the last name of the customer who placed an order for sales id 178? [/INST]
|
SELECT T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesID = 178;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List down product ids that were purchased by customers called Abby. [/INST]
|
SELECT DISTINCT T1.ProductID FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Abby';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Write down all of the product ids that were placed by Meander. [/INST]
|
SELECT DISTINCT T2.ProductID FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T1.FirstName = 'Meander';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the last name of sales person for sales id 100? [/INST]
|
SELECT T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T2.SalesID = 100;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the first name of employee who handled sales for customer called Abigail? [/INST]
|
SELECT DISTINCT T3.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T1.FirstName = 'Abigail';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many free gifts have customer with id 11782 received? [/INST]
|
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.CustomerID = 11782 AND T1.Price = 0;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the full name of customers who dealt with sales person with id 5? [/INST]
|
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesPersonID = 5;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List down all of the sales IDs for sales handled by sales people with first name starting with alphabet "s". [/INST]
|
SELECT T1.SalesID FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE SUBSTR(T2.FirstName, 1, 1) = 's';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among customers with IDs from 1 to 100, what is the highest price of products they purchased? [/INST]
|
SELECT T1.Price FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.CustomerID BETWEEN 1 AND 100 ORDER BY T1.Price DESC LIMIT 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among customers with the last name of Valdez, who purchased the highest quantity? [/INST]
|
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.LastName = 'Valdez' ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Sum up the number sales ids handled by employees called Morningstar, Heather and Dean. [/INST]
|
SELECT SUM(IIF(T2.FirstName = 'Morningstar', 1, 0)) + SUM(IIF(T2.FirstName = 'Heather', 1, 0)) + SUM(IIF(T2.FirstName = 'Dean', 1, 0)) AS num FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Has Alex purchased product with id 498? [/INST]
|
SELECT IIF(T1.ProductID = 498, 'YES', 'NO') FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Alex';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total price of products purchased by Adam. [/INST]
|
SELECT SUM(T3.Price * T2.quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Adam';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total price for products from id 400 to 500. [/INST]
|
SELECT SUM(T1.Price * T2.quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID BETWEEN 400 AND 500;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total quantity of products with name starting with alphabet "c". [/INST]
|
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE SUBSTR(T1.Name, 1, 1) = 'C';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total quantity of products purchased by customer called Adrian. [/INST]
|
SELECT SUM(T2.Quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Adam';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: List the product ID of the top five products, by descending order, in terms of price. [/INST]
|
SELECT ProductID FROM Products ORDER BY Price DESC LIMIT 5;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: Among the products, how many of them are freebies? [/INST]
|
SELECT COUNT(ProductID) FROM Products WHERE Price = 0;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Write down the name of products whose sale quantity is more than 950. [/INST]
|
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 950;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the full name of employee who sold 1000 units? [/INST]
|
SELECT DISTINCT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T1.Quantity = 1000;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Tally the product name and quantity of the first ten sales. [/INST]
|
SELECT T3.Name, T2.Quantity FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T2.SalesID BETWEEN 1 AND 10;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the total sales amount for Reflector? [/INST]
|
SELECT SUM(T1.Price * T2.quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Reflector';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the best selling colour for HL Mountain Frame, 42? [/INST]
|
SELECT IIF(SUM(IIF(T1.Name = 'HL Mountain Frame - Silver, 42', T2.SalesID, 0)) - SUM(IIF(T1.Name = 'HL Mountain Frame - Black, 42', T2.SalesID, 0)) > 0, 'Silver', 'Black') FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: What is the difference in price between HL Mountain Frame - Black, 42 and LL Mountain Frame - Black, 42? [/INST]
|
SELECT ( SELECT Price FROM Products WHERE Name = 'HL Mountain Frame - Black, 42' ) - ( SELECT Price FROM Products WHERE Name = 'LL Mountain Frame - Black, 42' ) AS num;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total number of sales closed by Michel E. DeFrance? [/INST]
|
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T2.FirstName = 'Michel' AND T2.MiddleInitial = 'e' AND T2.LastName = 'DeFrance';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the average number of customers per sales person? [/INST]
|
SELECT CAST(COUNT(T1.CustomerID) AS REAL) / COUNT(T3.EmployeeID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among all customers handled by Innes E. del Castillo, how many have purchased Short-Sleeve Classic Jersey, L? [/INST]
|
SELECT COUNT(T2.CustomerID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T3.FirstName = 'Innes' AND T3.LastName = 'del Castillo' AND T1.Name = 'Short-Sleeve Classic Jersey, L' AND T3.MiddleInitial = 'e';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48. [/INST]
|
SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID INNER JOIN Customers AS T4 ON T2.CustomerID = T4.CustomerID WHERE T4.MiddleInitial = 'A' AND T4.LastName = 'White' AND T1.Name = 'Road-250 Black, 48' AND T4.FirstName = 'Elizabeth';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many sales people managed to sell Headlights - Weatherproof? [/INST]
|
SELECT COUNT(T2.SalesPersonID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Headlights - Weatherproof';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the revenue produced through sales of HL Road Frame - Red, 56. [/INST]
|
SELECT SUM(T2.Quantity * T1.Price) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Road Frame - Red, 56';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many sales transactions were given by the customer named Joe L. Lopez? [/INST]
|
SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Joe' AND T2.MiddleInitial = 'L' AND T2.LastName = 'Lopez';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Name the customers who received 'Touring Rim' as a free gift. [/INST]
|
SELECT DISTINCT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T3.Name = 'Touring Rim' AND T3.Price = 0;
|
[INST] Here is a database schema:
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Find the number of customers handled by each of the sales people. [/INST]
|
SELECT COUNT(CustomerID) FROM Sales GROUP BY SalesPersonID;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: How many sales people are handling all the customers? [/INST]
|
SELECT COUNT(EmployeeID) FROM Employees;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: Identify the name of the sales person with employee ID 7. [/INST]
|
SELECT FirstName, MiddleInitial, LastName FROM Employees WHERE EmployeeID = 7;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: Name the most expensive and the least expensive products available, excluding free gifts. [/INST]
|
SELECT Name FROM Products WHERE Price IN (( SELECT MAX(Price) FROM Products ), ( SELECT MIN(Price) FROM Products ));
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among all the customers who have purchased ML Bottom Bracket, identify the percentage of sales by Albert I. Ringer? [/INST]
|
SELECT CAST(SUM(IIF(T3.FirstName = 'Albert' AND T3.MiddleInitial = 'I' AND T3.LastName = 'Ringer', 1, 0)) AS REAL) * 100 / COUNT(T2.CustomerID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T1.Name = 'ML Bottom Bracket';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: How many customers have the first name Abigail? [/INST]
|
SELECT COUNT(CustomerID) FROM Customers WHERE FirstName = 'Abigail';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Indicate the quantity of Blade products sold. [/INST]
|
SELECT DISTINCT T2.Quantity FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Blade';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the full name of the employee who has sold the most quantity. [/INST]
|
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the full name of the customer who purchased the most quantity of products. [/INST]
|
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the product that is most sold by sale person id 20? [/INST]
|
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesPersonID = 20 ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the first names of employees with trading quantity for more than 500. [/INST]
|
SELECT DISTINCT T1.FirstName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID WHERE T2.Quantity > 500;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the first names of customers who have purchased products from sale person id 1. [/INST]
|
SELECT T1.FirstName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.SalesPersonID = 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total trading quantity of Abraham sold to Aaron Alexander. [/INST]
|
SELECT SUM(T2.Quantity) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Employees AS T3 ON T2.SalesPersonID = T3.EmployeeID WHERE T2.SalesPersonID = 1 AND T1.FirstName = 'Aaron' AND T1.LastName = 'Alexander' AND T3.FirstName = 'Abraham';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the full names of customers who have purchased products in quantity over 600. [/INST]
|
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Quantity > 600;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the customers whose first name is Cameron, who bought the product in the most quantity? [/INST]
|
SELECT T1.FirstName, T1.LastName FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Cameron' ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Please provide sales ID for products named Hex Nut with a price greater than 100. [/INST]
|
SELECT T2.SalesID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Hex Nut%' AND T1.Price > 100;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Identify customer IDs who bought products priced from 1000 to 2000. [/INST]
|
SELECT DISTINCT T2.CustomerID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price BETWEEN 1000 AND 2000;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the total quantity of products that are gifts. [/INST]
|
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price = 0;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the quantity percentage of the gift products in the total trading quantity. [/INST]
|
SELECT CAST(SUM(IIF(T1.Price = 0, T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity)FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Calculate the percentage of sold blades in the total number of transactions. [/INST]
|
SELECT CAST(SUM(IIF(T1.Name = 'Blade', T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: How many of the employees have the last name "Ringer" ? [/INST]
|
SELECT COUNT(LastName) FROM Employees WHERE LastName = 'Ringer';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: Among the products with product ID lower than 15, how many of them costs 10 and below? [/INST]
|
SELECT COUNT(ProductID) FROM Products WHERE ProductID < 15 AND Price <= 10;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the product's name brought by Aaron Alexander. [/INST]
|
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Aaron' AND T3.LastName = 'Alexander';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the product ID and name of the product with the highest prices among the quantity ranges from 400 to 500. [/INST]
|
SELECT T1.ProductID, T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity BETWEEN 400 AND 500 ORDER BY T1.Price DESC LIMIT 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among customers named Kate, who has the highest quantity? [/INST]
|
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Kate' ORDER BY T1.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the products that have price ranges from 100 to 150, what is the customer ID and sales ID of the product with a quantity lower than 25? [/INST]
|
SELECT T2.CustomerID, T2.SalesID FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Price BETWEEN 100 AND 150 AND T2.Quantity < 25;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the quantity and price of the product bought by Abigail Henderson. [/INST]
|
SELECT T2.Quantity, T1.Price FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Abigail' AND T3.LastName = 'Henderson';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: In sales with a quantity of 60, how many of them have a price not greater than 500? [/INST]
|
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T2.quantity = 60 AND T1.Price <= 500;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: In customers with the first name of Erica, how many of them bought a quantity below 200? [/INST]
|
SELECT COUNT(T1.ProductID) FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.FirstName = 'Erica' AND T1.Quantity < 200;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among products bought by Kathryn Ashe, what is the name of the product with the highest quantity? [/INST]
|
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Kathryn' AND T3.LastName = 'Ashe' ORDER BY T2.Quantity DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the price and quantity of the product named Seat Tube? [/INST]
|
SELECT DISTINCT T2.Price, T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Seat Tube';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the price and name of the product bought by Erica Xu? [/INST]
|
SELECT T3.Price, T3.Name FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID WHERE T2.FirstName = 'Erica' AND T2.LastName = 'Xu';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the sales ID of the product with a quantity of 590 and named "External Lock Washer 7". [/INST]
|
SELECT T1.SalesID FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'External Lock Washer 7' AND T1.Quantity = 590;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: In sales ID between 30 and 40, who is the customer that bought a total quantity of 403? [/INST]
|
SELECT T2.FirstName, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity = 403 AND T1.SalesID BETWEEN 30 AND 40;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: List the customer's ID and last name of the customer that purchased a product with a quantity greater than 90% of the average quantity of all listed products. [/INST]
|
SELECT T2.CustomerID, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Quantity > ( SELECT AVG(Quantity) FROM Sales ) * 0.9;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the sales ID ranges from 1 to 200, what is the percentage of the products with a price ranging from 200 to 300? [/INST]
|
SELECT CAST(SUM(IIF(T2.Price BETWEEN 200 AND 300, 1, 0)) AS REAL) * 100 / COUNT(T2.Price) FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SalesID BETWEEN 1 AND 200;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the most expensive product? [/INST]
|
SELECT Name FROM Products WHERE Price = ( SELECT MAX(Price) FROM Products );
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: How many customers are named Madison? [/INST]
|
SELECT COUNT(CustomerID) FROM Customers WHERE FirstName = 'Madison';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: How many types of "HL Touring Frames" are there? [/INST]
|
SELECT COUNT(ProductID) FROM Products WHERE Name LIKE '%HL Touring Frame%';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Please write me a SQL statement that answers the following question: How many customers share the most common last name? [/INST]
|
SELECT COUNT(CustomerID) FROM Customers GROUP BY LastName ORDER BY COUNT(LastName) DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Please write me a SQL statement that answers the following question: How many free or gift products are there? [/INST]
|
SELECT COUNT(ProductID) FROM Products WHERE Price = 0;
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the name of the sales person who handled the highest number of sales? [/INST]
|
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T2.SalesPersonID = T1.EmployeeID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 1;
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the full name of the customer who purchased the highest amount of total price in a single purchase? [/INST]
|
SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID GROUP BY T1.SalesID, T1.Quantity, T3.Price, FirstName, MiddleInitial, LastName ORDER BY T1.Quantity * T3.Price DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many "Mountain-500 Black 42" were sold in total? [/INST]
|
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain-500 Black, 42';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How much is the total amount of sales handled by Heather McBadden? [/INST]
|
SELECT SUM(T2.Quantity * T3.Price) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Heather' AND T1.LastName = 'McBadden';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many "Mountain-100 Silver, 38" were sold by Stearns MacFeather? [/INST]
|
SELECT SUM(T2.Quantity) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Stearns' AND T1.LastName = 'MacFeather' AND T3.Name = 'Mountain-100 Silver, 38';
|
[INST] Here is a database schema:
Customers :
CustomerID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many type of products did Dalton M. Coleman purchase? [/INST]
|
SELECT COUNT(T2.ProductID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Dalton' AND T1.MiddleInitial = 'M' AND T1.LastName = 'Coleman';
|
[INST] Here is a database schema:
Employees :
EmployeeID [ INTEGER ] primary_key
FirstName [ TEXT ]
MiddleInitial [ TEXT ]
LastName [ TEXT ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: What are the full names of the top 3 employees who handled the highest number of sales? [/INST]
|
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 3;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the "Mountain-500 Black" product types, which type was purchased the most? [/INST]
|
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Mountain-500 Black%' GROUP BY T2.Quantity, T1.Name ORDER BY SUM(T2.Quantity) DESC LIMIT 1;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many employees sold "ML Road Frame-W - Yellow, 40"? [/INST]
|
SELECT COUNT(T2.SalesPersonID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'ML Road Frame-W - Yellow, 40';
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many chainring bolts were sold under sales ID 551971? [/INST]
|
SELECT T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Chainring Bolts' AND T1.SalesID = 551971;
|
[INST] Here is a database schema:
Products :
ProductID [ INTEGER ] primary_key
Name [ TEXT ]
Price [ REAL ]
Sales :
SalesID [ INTEGER ] primary_key
SalesPersonID [ INTEGER ] Sales.SalesPersonID = Employees.EmployeeID
CustomerID [ INTEGER ] Sales.CustomerID = Customers.CustomerID
ProductID [ INTEGER ] Sales.ProductID = Products.ProductID
Quantity [ INTEGER ]
Please write me a SQL statement that answers the following question: How many employees sold over 20,000 quantities of "Touring-2000 Blue, 50"? [/INST]
|
SELECT COUNT(*) FROM ( SELECT SUM(Quantity) FROM Sales WHERE ProductID IN ( SELECT ProductID FROM Products WHERE Name = 'Touring-2000 Blue, 50' ) GROUP BY Quantity, SalesPersonID HAVING SUM(Quantity) > 20000 );
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.