input
stringlengths
193
2.69k
output
stringlengths
24
744
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What are the products by the company "Bigfoot Breweries"? [/INST]
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Bigfoot Breweries';
[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 are the names of Robert King's territories? [/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.LastName = 'King' AND T1.FirstName = 'Robert';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Provide the name of the contact person who made the orders that shipped to Switzerland. [/INST]
SELECT T1.ContactName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.ShipCountry = 'Switzerland' GROUP BY T1.ContactName;
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: What proportion of orders are taken by the Sales Representative? [/INST]
SELECT CAST(COUNT(CASE WHEN T1.Title = 'Sales Representative' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID;
[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 USA employess, how many of them has PhD title of courtesy? [/INST]
SELECT COUNT(Country) FROM Employees WHERE TitleOfCourtesy = 'Dr.' AND Country = 'USA';
[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 for employees from ID 1 to 9? [/INST]
SELECT AVG(Salary) FROM Employees WHERE EmployeeID BETWEEN 1 AND 9;
[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: Calculate the total salary for employees from UK. [/INST]
SELECT SUM(Salary) FROM Employees WHERE 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: Is (206) 555-1189 the home phone number for Laura Callahan? [/INST]
SELECT CASE WHEN HomePhone = '(206) 555-1189' THEN 'YES' ELSE 'NO' END FROM Employees WHERE 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: Write down the notes of employee with the highest salary. [/INST]
SELECT Notes 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 ] 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 that answers the following question: List down the customer ids who placed order with Michael Suyama. [/INST]
SELECT T2.CustomerID 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 ] 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 that answers the following question: Where are the ship countries of orders placed by Janet Leverling? [/INST]
SELECT DISTINCT T2.ShipCountry FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Janet' AND T1.LastName = 'Leverling';
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: How many orders have Margaret Peacock placed? [/INST]
SELECT COUNT(T2.EmployeeID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Margaret' AND T1.LastName = 'Peacock';
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Calculate the average salary per order for Andrew Fuller. [/INST]
SELECT CAST(SUM(T1.Salary) AS REAL) / COUNT(T2.EmployeeID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Andrew' AND T1.LastName = 'Fuller';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What are the product names of Exotic Liquids? [/INST]
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Exotic Liquids';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: List down the quantity per unit for products of Tokyo Traders. [/INST]
SELECT T1.QuantityPerUnit FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Tokyo Traders';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: How many products have been discountinued by New Orleans Cajun Delights? [/INST]
SELECT COUNT(T1.Discontinued) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'New Orleans Cajun Delights';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Please calculate the average unit price for products of Formaggi Fortini s.r.l. [/INST]
SELECT SUM(T1.UnitPrice) / COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Formaggi Fortini s.r.l.';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Calculate the total products that are supplied by Japan suppliers. [/INST]
SELECT COUNT(T1.SupplierID) 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the contact name for product Teatime Chocolate Biscuits? [/INST]
SELECT T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName = 'Teatime Chocolate Biscuits';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: List down the company names that have the highest reorder level. [/INST]
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: 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the contact title for the person who supplied a product that is 10 boxes x 12 pieces. [/INST]
SELECT T2.ContactTitle FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.QuantityPerUnit = '10 boxes x 12 pieces';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the total units on order from Exotic Liquids? [/INST]
SELECT SUM(T1.UnitsOnOrder) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Exotic Liquids';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Calculate the percentage of products supplied by Gai pturage over all products. [/INST]
SELECT CAST(COUNT(CASE WHEN T2.CompanyName = 'Gai pturage' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID;
[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 following question: List the product ID of the top five products, by descending order, the number of quantities in stock. [/INST]
SELECT ProductID FROM Products ORDER BY UnitsInStock DESC LIMIT 5;
[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 following question: Among the products, how many of them were discontinued in production? [/INST]
SELECT COUNT(*) 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: Give me the address, home phone and salary of the Sales Manager. [/INST]
SELECT Address, HomePhone, Salary FROM Employees WHERE Title = 'Sales Manager';
[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 Vice President of Sales. Give me the URL of his/her photo. [/INST]
SELECT FirstName, LastName FROM Employees WHERE Title = 'Vice President, Sales';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: List the products whose supplier is Pavlova, Ltd. Please include the product ID and re-order level. [/INST]
SELECT T1.ProductName, T1.ProductID, T1.ReorderLevel 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: 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Who are the suppliers of the discontinued products? [/INST]
SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.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: Among the employees, give me the full names of those who have less than 4 territories. [/INST]
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.EmployeeID < 4;
[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 territories in the Eastern region? [/INST]
SELECT COUNT(DISTINCT T1.FirstName) 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';
[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 [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: From 1/3/97 to 8/10/97, how many orders were shipped via Federal Shipping? [/INST]
SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShippedDate BETWEEN '1997-03-01 00:00:00' AND '1997-10-08 23:59:59';
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Tally the customer ID of orders that were shipped to Brazil by Margaret Peacock from 3/31/97 to 12/10/97. [/INST]
SELECT DISTINCT T2.CustomerID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.LastName = 'Peacock' AND T1.FirstName = 'Margaret' AND T2.ShipCountry = 'Brazil' AND T2.ShippedDate BETWEEN '1997-03-31 00:00:00' AND '1997-12-10 23:59:59';
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the stock value of every condiments? [/INST]
SELECT T1.UnitPrice * T1.UnitsInStock FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID;
[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 territories are owned by Anne Dodsworth? [/INST]
SELECT COUNT(T2.TerritoryID) FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Anne' AND T1.LastName = 'Dodsworth';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Which of the American customers have experienced a delay in the shipment and how long was the longest? [/INST]
SELECT T1.CompanyName, TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Country = 'USA' AND TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) < 0;
[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 Berlin, Germany? [/INST]
SELECT COUNT(City) FROM Customers WHERE Country = 'Germany' AND City = 'Berlin';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: How many products does the company Exotic Liquids supply? [/INST]
SELECT COUNT(T1.ProductName) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Exotic Liquids';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Which company has the lowest unit price? Please give the company name and the product name. [/INST]
SELECT T2.CompanyName, T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitPrice = ( SELECT MIN(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 ] 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 following question: What is the average unit price of Tokyo Traders' products? [/INST]
SELECT SUM(T1.UnitPrice) / COUNT(T2.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Tokyo Traders';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: What percentage of orders were placed by customers in Madrid city in 1996? [/INST]
SELECT CAST(COUNT(CASE WHEN T1.City = 'Madrid' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.City) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = 1996;
[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 names and titles of all employees. [/INST]
SELECT FirstName, LastName, Title 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 has the highest salary? Please give their first 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 many sales representatives whose salaries are higher than 2000? [/INST]
SELECT COUNT(Title) FROM Employees WHERE Salary > 2000 AND Title = 'Sales Representative';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: In 1996, how many orders were from customers in the UK? [/INST]
SELECT COUNT(T1.CustomerID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1996' AND T1.Country = 'UK';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Which company had the most orders in 1998? [/INST]
SELECT T1.CompanyName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1998' GROUP BY T1.CompanyName ORDER BY COUNT(T2.OrderID) 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 ] 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 that answers the following question: Please calculate the number of orders from customers by country in 1996. [/INST]
SELECT COUNT(T2.CustomerID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1996' GROUP BY T1.Country;
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: How many orders were from Hanna Moos company in 1999? [/INST]
SELECT COUNT(T2.OrderID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1999' AND T1.CompanyName = 'Hanna Moos';
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: How many days was the fastest shipping of Berglunds snabbkp's order? [/INST]
SELECT datediff(T2.ShippedDate, T2.OrderDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.CompanyName = 'Berglunds snabbkp' ORDER BY datediff(T2.ShippedDate, T2.OrderDate) 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 ] 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 that answers the following question: Which company placed the order with the id 10257? [/INST]
SELECT T1.CompanyName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10257;
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: In which year did Around the Horn place the most orders? [/INST]
SELECT STRFTIME('%Y', T2.OrderDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.CompanyName = 'Around the Horn' GROUP BY STRFTIME('%Y', T2.OrderDate) ORDER BY COUNT(T2.OrderID) 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: How many employees report to Andrew Fuller? [/INST]
SELECT COUNT(EmployeeID) FROM Employees WHERE ReportsTo = ( SELECT EmployeeID FROM Employees WHERE LastName = 'Fuller' AND FirstName = 'Andrew' );
[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: Which country are the majority of the suppliers located? [/INST]
SELECT Country FROM Suppliers GROUP BY Country ORDER BY COUNT(SupplierID) 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 full name of the employees who report to the Sales Manager? [/INST]
SELECT FirstName, LastName FROM Employees WHERE ReportsTo = ( SELECT EmployeeID FROM Employees WHERE Title = 'Sales Manager' );
[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 that answers the following question: In August of 1996, how many orders were placed by the customer with the highest amount of orders? [/INST]
SELECT COUNT(OrderID) FROM Orders WHERE OrderDate LIKE '1996-08%' GROUP BY CustomerID ORDER BY COUNT(OrderID) 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: How much is the salary of the first employee that was hired? [/INST]
SELECT Salary FROM Employees WHERE HireDate = ( SELECT MIN(HireDate) 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 old was the oldest employee at the time he or she was hired? [/INST]
SELECT MAX(TIMESTAMPDIFF(YEAR, BirthDate, HireDate)) FROM Employees;
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the category of the product that has the highest number of discontinued products? [/INST]
SELECT T2.CategoryName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.Discontinued = 1 GROUP BY T2.CategoryName ORDER BY COUNT(T1.ProductID) DESC LIMIT 1;
[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 [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: What is the monthly average number of products shipped via Federal Shipping for the year 1996? [/INST]
SELECT CAST(SUM(T1.ShipVia) AS REAL) / 12 FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShippedDate LIKE '1996%';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Which products are being supplied by "G'day, Mate"? List all of their names. [/INST]
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName LIKE 'G%day, Mate';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What is the company name of the supplier who supplies the product with the highest unit price? [/INST]
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: How many female employees are in charge of 3 or more territories? [/INST]
SELECT COUNT(EID) FROM ( SELECT T1.EmployeeID AS EID FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.TitleOfCourtesy IN ('Ms.' OR 'Mrs.') GROUP BY T1.EmployeeID HAVING COUNT(T2.TerritoryID) >= 3 ) T1;
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Who are the top 8 suppliers supplying the products with the highest user satisfaction? [/INST]
SELECT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID ORDER BY T1.ReorderLevel DESC LIMIT 8;
[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 that answers the following question: How many orders were shipped to Venezuela in 1996? [/INST]
SELECT COUNT(OrderID) FROM Orders WHERE ShipCountry = 'Venezuela' AND STRFTIME('%Y', ShippedDate) = '1996';
[INST] Here is a database schema: Categories : CategoryID [ INTEGER ] primary_key CategoryName [ TEXT ] Description [ TEXT ] Please write me a SQL statement that answers the following question: What are the ID and description of the condiments category? [/INST]
SELECT CategoryID, Description FROM Categories WHERE CategoryName = 'Condiments';
[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: Provide the supplier company name in Sydney and its homepage address if available. [/INST]
SELECT CompanyName, HomePage FROM Suppliers WHERE City = 'Sydney';
[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: Write down the full name of Vie President of Sales and his age when he was hired. [/INST]
SELECT FirstName, LastName , TIMESTAMPDIFF(YEAR, BirthDate, HireDate) AS AGE FROM Employees WHERE Title = 'Vice President, Sales';
[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: List the supplier company names located in Germany. [/INST]
SELECT CompanyName FROM Suppliers WHERE Country = 'Germany';
[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: List the employees' full names and ages in 2022 who lived in London. [/INST]
SELECT TitleOfCourtesy, FirstName, LastName , TIMESTAMPDIFF(YEAR, BirthDate, NOW()) AS ages FROM Employees WHERE City = 'London';
[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: List down the customer company names, addresses, phones and faxes which are located in London. [/INST]
SELECT CompanyName, Address, Phone, Fax FROM Customers WHERE 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: List the full name of employees and titles who have to report to Sales Manager. [/INST]
SELECT FirstName, LastName, Title FROM Employees WHERE ReportsTo = ( SELECT EmployeeID FROM Employees WHERE Title = 'Sales Manager' );
[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: List all the customer company names and cities located in Canada. [/INST]
SELECT CompanyName, City FROM Customers WHERE Country = 'Canada';
[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 following question: Find the total production amount and product names which had "10 - 500 g pkgs." as quantity per unit. [/INST]
SELECT UnitsInStock + UnitsOnOrder, ProductName FROM Products WHERE QuantityPerUnit = '10 - 500 g pkgs.';
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: List all the product names and categories of the highest reorder level. [/INST]
SELECT T2.ProductName, T1.CategoryName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID ORDER BY T2.ReorderLevel 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Describe the supplier companies, cities and products which total production amount is more than 120. [/INST]
SELECT T2.CompanyName, T2.City, T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitsInStock + UnitsOnOrder > 120;
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Provide the contact person name, title and supplied products by "Escargots Nouveaux" company. [/INST]
SELECT T2.ContactName, T2.ContactTitle, T1.ProductName 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: 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: List the territory IDs, description and region description under the in-charge of Mrs. Margaret Peacock. [/INST]
SELECT T3.TerritoryID, T3.TerritoryDescription, 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 WHERE T1.TitleOfCourtesy = 'Mrs.' AND T1.LastName = 'Peacock' AND T1.FirstName = 'Margaret';
[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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: What were the products supplied by the company in Spain? [/INST]
SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Spain';
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Provide the list of product IDs and names under the meat/poultry category. [/INST]
SELECT T2.ProductName, T1.CategoryName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products );
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: How many orders were made by the customers in Ireland. [/INST]
SELECT COUNT(T2.OrderID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Country = 'Ireland';
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Mention the oldest empoyee's full name, title, salary and number of orders which were shipped to USA by him. [/INST]
SELECT T1.FirstName, T1.LastName, T1.Title, T1.Salary , COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE ShipCountry = 'USA' GROUP BY T1.FirstName, T1.LastName, T1.Title, T1.Salary, T1.BirthDate ORDER BY T1.BirthDate 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Calculate the total production for each product which were supplied from Japan [/INST]
SELECT SUM(T1.UnitsInStock + T1.UnitsOnOrder) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Japan';
[INST] Here is a database schema: Categories : CategoryID [ INTEGER ] primary_key CategoryName [ TEXT ] Description [ TEXT ] 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Among the supplied products from Australia, describe the discontinued products and the category. [/INST]
SELECT T2.ProductName, T3.CategoryName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T1.Country = 'Australia' AND T2.Discontinued = 1;
[INST] Here is a database schema: Categories : CategoryID [ INTEGER ] primary_key CategoryName [ TEXT ] Description [ TEXT ] 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 = Suppliers.SupplierID CategoryID [ INTEGER ] Products.CategoryID = Categories.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Among the products under grains/cereals category, provide the contact person and title of the supplier with one digit ID. [/INST]
SELECT DISTINCT T1.ContactName, T1.ContactTitle FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T3.CategoryName = 'Grains/Cereals' AND T1.SupplierID BETWEEN 1 AND 10 LIMIT 1;
[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 [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Provide Speedy Express's phone number and number of shipped orders on 30th January, 1998. [/INST]
SELECT T2.Phone, COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Speedy Express' AND T1.ShippedDate LIKE '1998-01-30%' GROUP BY T2.Phone;
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Identify the name of the most popular dairy product in terms of reorder quantity. [/INST]
SELECT T2.ProductName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.CategoryName = 'Dairy Products' AND T2.ReorderLevel = ( SELECT MAX(ReorderLevel) FROM Products );
[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 following question: Calculate the production volume of the dairy product 'Mascarpone Fabioli'. [/INST]
SELECT SUM(UnitsInStock + UnitsOnOrder) FROM Products WHERE ProductName = 'Mascarpone Fabioli';
[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.CategoryID Unit [ TEXT ] Price [ REAL ] Please write me a SQL statement that answers the following question: Identify the name and product category for the most expensive and the least expensive products. [/INST]
SELECT T2.ProductName, T1.CategoryName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.UnitPrice IN (( SELECT MIN(UnitPrice) FROM Products ), ( SELECT MAX(UnitPrice) FROM Products ));
[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 following question: Find the percentage of discontinued products in Northwind's portfolio of products. [/INST]
SELECT CAST(COUNT(CASE WHEN Discontinued = 1 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(ProductID) FROM Products;
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Provide the full name of the employee who processed the sales order with ID 10274. [/INST]
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10274;
[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 ] Orders.EmployeeID = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Calculate the total number of orders placed by the company 'GROSELLA-Restaurante'. [/INST]
SELECT COUNT(T2.OrderID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.CompanyName = 'GROSELLA-Restaurante';
[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 salary range for sales representative in Northwind? [/INST]
SELECT ( SELECT MIN(Salary) FROM Employees WHERE Title = 'Sales Representative' ) AS MIN , ( SELECT MAX(Salary) FROM Employees WHERE Title = 'Sales Representative' ) AS MAX;
[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 does Northwind have in USA? [/INST]
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 following question: What products are no longer sold by Northwind? [/INST]
SELECT ProductName FROM Products WHERE Discontinued = 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: Who is the Sales Agent for the company 'Eastern Connection'? [/INST]
SELECT ContactName FROM Customers WHERE CompanyName = 'Eastern Connection' AND ContactTitle = 'Sales Agent';
[INST] Here is a database schema: Shippers : ShipperID [ INTEGER ] primary_key ShipperName [ TEXT ] Phone [ TEXT ] Please write me a SQL statement that answers the following question: How many companies do ship Northwind's orders? [/INST]
SELECT COUNT(ShipperID) FROM Shippers;
[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 = Employees.EmployeeID OrderDate [ DATETIME ] ShipperID [ INTEGER ] Orders.ShipperID = Shippers.ShipperID Please write me a SQL statement that answers the following question: Identify the total number of orders processed by Northwind employee named Andrew Fuller. What percent of those orders was shipped to Austria? [/INST]
SELECT CAST(COUNT(CASE WHEN T2.ShipCountry = 'Austria' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Andrew' AND T1.LastName = 'Fuller';
[INST] Here is a database schema: Categories : CategoryID [ INTEGER ] primary_key CategoryName [ TEXT ] Description [ TEXT ] Please write me a SQL statement that answers the following question: Indicate category name of soft drinks, coffees, teas, beers, and ales in description list. [/INST]
SELECT CategoryName FROM Categories WHERE Description = 'Soft drinks, coffees, teas, beers, and ales';
[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: List the phone number of company named Around the Horn. [/INST]
SELECT Phone FROM Customers WHERE CompanyName = 'Around the Horn';
[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: Indicate the fax of the company Blondesddsl pre et fils in Strasbourg city. [/INST]
SELECT Fax FROM Customers WHERE CompanyName = 'Blondesddsl pre et fils' AND City = 'Strasbourg';