input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total value of cancelled orders? [/INST]
SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T2.status = 'Cancelled';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Please calculate the total value of Motorcycles orders. [/INST]
SELECT SUM(T1.quantityOrdered * T1.priceEach) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Motorcycles';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many Planes orders were there? [/INST]
SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productLine = 'Planes';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many orders which expected profits greater than 100? [/INST]
SELECT COUNT(T1.productCode) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.MSRP - T2.buyPrice > 100;
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Please calculate the average total price of orders from Exoto Designs Vendor in 2005. [/INST]
SELECT SUM(T2.quantityOrdered * T2.priceEach) / COUNT(T3.orderNumber) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T1.productVendor = 'Exoto Designs' AND STRFTIME('%Y', T3.orderDate) = '2005';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: How many sales representatives who have office code is 1? [/INST]
SELECT COUNT(officeCode) FROM employees WHERE jobTitle = 'Sales Rep' AND officeCode = 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Please list different customer names with the payment amount of over 50,000. [/INST]
SELECT DISTINCT T2.customerName FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.amount > 50000;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Please calculate the total payment amount of customers who come from the USA. [/INST]
SELECT SUM(T1.amount) FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.country = 'USA';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: What are the total payments of customers with no credit limit in 2003? [/INST]
SELECT SUM(amount) FROM payments WHERE STRFTIME('%Y', paymentDate) = '2003' AND customerNumber IN ( SELECT customerNumber FROM customers WHERE creditLimit = 0 );
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: Please list the name and phone number of the customer whose order was cancelled. [/INST]
SELECT T2.customerName, T2.phone FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Cancelled';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: How many French customers shipped 2 orders which have been cancelled? [/INST]
SELECT COUNT(T2.country) FROM orders AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.status = 'Shipped' AND T2.country = 'France' GROUP BY T2.customerNumber HAVING COUNT(T1.status) = 2;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Please calculate the average total price of shipped orders from German customers. [/INST]
SELECT SUM(T3.quantityOrdered * T3.priceEach) / COUNT(T2.orderNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber INNER JOIN orderdetails AS T3 ON T2.orderNumber = T3.orderNumber WHERE T2.status = 'Shipped' AND T1.country = 'Germany';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: List out full name of employees who are working in Tokyo? [/INST]
SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: How many Sales Rep who are working in Tokyo? List out email and full name of those employees. [/INST]
SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Tokyo' AND T1.jobTitle = 'Sales Rep';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: State the email of those who are staff of Murphy Diane whose number is 1002 and living in San Francisco [/INST]
SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1002 AND T2.city = 'San Francisco';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: Determine the email and Code of employee who are working at United State, state MA [/INST]
SELECT T1.email, T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.state = 'MA' AND T2.country = 'USA';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: How many Sales Manager who are working in Sydney? List out their email. [/INST]
SELECT T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.jobTitle LIKE '%Sales Manager%' AND T2.city = 'Sydney';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: How many employees who are living in Australia and have the credit limit under 200000? State their email address and countries where they are working. [/INST]
SELECT T2.email, T3.country FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber INNER JOIN offices AS T3 ON T2.officeCode = T3.officeCode WHERE T3.country = 'Australia' AND T1.creditLimit < 200000 AND T2.jobTitle = 'Sales Rep';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: State 10 emails of UK Sales Rep who have the lowest credit limit. [/INST]
SELECT DISTINCT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' ORDER BY T1.creditLimit LIMIT 10;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: How many Australian customers who have credit line under 220000? [/INST]
SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Australia';
[INST] Here is a database schema: payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: List out 3 customer numbers who have highest amount payment [/INST]
SELECT customerNumber FROM payments ORDER BY amount DESC LIMIT 3;
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: Determine the email and Code of employee who are working at United State, state CA [/INST]
SELECT T1.email, T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.country = 'USA' AND T2.state = 'CA' GROUP BY T1.email, T1.officeCode;
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: List out full name of employees who are working in Boston? [/INST]
SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Boston';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: State top 3 emails of UK Sales Rep who have the highest credit limit. [/INST]
SELECT T2.email FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep' AND T1.country = 'UK' GROUP BY T1.customerName, T2.email ORDER BY SUM(T1.creditLimit) DESC LIMIT 3;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: How many customers who are in Norway and have credit line under 220000? [/INST]
SELECT COUNT(creditLimit) FROM customers WHERE creditLimit < 220000 AND country = 'Norway';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: List out full name and email of employees who are working in Paris? [/INST]
SELECT T1.firstName, T1.lastName, T1.email FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Paris';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] Please write me a SQL statement that answers the following question: List the product code of the top five motorcycles, by descending order, the number of quantity in stock. [/INST]
SELECT productCode, quantityInStock FROM products WHERE productLine = 'Motorcycles' ORDER BY quantityInStock DESC LIMIT 5;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Among the German customers, how many of the them has credit limit of zero? [/INST]
SELECT COUNT(customerNumber) FROM customers WHERE creditLimit = 0 AND country = 'Germany';
[INST] Here is a database schema: payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: From 2003 to 2004, how many customers have paid more than three times? [/INST]
SELECT COUNT(customernumber) FROM ( SELECT customernumber FROM payments WHERE STRFTIME('%Y', paymentDate) >= '2003' AND STRFTIME('%Y', paymentDate) <= '2004' GROUP BY customernumber HAVING COUNT(customernumber) > 3 ) T;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the average actual profit by 1937 Lincoln Berline? [/INST]
SELECT SUM(T1.priceEach - T2.buyPrice) / COUNT(*) FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode WHERE T2.productName = '1937 Lincoln Berline';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers? [/INST]
SELECT T1.productName FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T1.productLine = 'Motorcycles' AND T1.productScale = '1:10' AND T4.country = 'USA' GROUP BY T1.productName ORDER BY SUM(T2.quantityOrdered) DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Between 8/1/2003 and 8/30/2004, how many checks were issued by Mini Gifts Distributors Ltd.? Please list their check numbers. [/INST]
SELECT T1.checkNumber FROM payments AS T1 INNER JOIN customers AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.paymentDate >= '2003-08-01' AND T1.paymentDate <= '2004-08-30' AND T2.customerName = 'Mini Gifts Distributors Ltd.';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: For the planes which has the hightest total price, how much it exceeds the average? [/INST]
SELECT MAX(quantityOrdered * priceEach) - AVG(priceEach) FROM orderdetails WHERE productCode IN ( SELECT productCode FROM products WHERE productLine = 'Planes' );
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total value of shipped vintage car orders from 2003-2004? [/INST]
SELECT SUM(T2.priceEach * T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber WHERE T3.status = 'Shipped' AND T3.orderDate BETWEEN '2003-01-01' AND '2004-12-31';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Who is the sales agent of the customer who has made the highest payment? Include the full names of employee and his/her supervisor. [/INST]
SELECT T1.firstName, T1.lastName, T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber ORDER BY T3.amount DESC LIMIT 1;
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the highest amount of order made by the sales representative in Boston? Please give the name of the product and amount. [/INST]
SELECT T2.productName, T1.quantityOrdered * T1.priceEach FROM orderdetails AS T1 INNER JOIN products AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T1.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T4.city = 'Boston' AND T4.salesRepEmployeeNumber IN ( SELECT employeeNumber FROM employees WHERE jobTitle = 'Sales Rep' ) ORDER BY T1.quantityOrdered DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total actual profit gained from orders made by American customers from 2003-01-06 to 2005-05-09? [/INST]
SELECT SUM(T2.priceEach - T1.buyPrice) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode INNER JOIN orders AS T3 ON T2.orderNumber = T3.orderNumber INNER JOIN customers AS T4 ON T3.customerNumber = T4.customerNumber WHERE T3.orderDate > '2003-01-05' AND T3.orderDate < '2005-05-10';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: From which branch does the sales representative employee who made the most sales in 2005? Please indicates its full address and phone number. [/INST]
SELECT T3.addressLine1, T3.addressLine2, T3.phone FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber INNER JOIN customers AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN employees AS T4 ON T3.salesRepEmployeeNumber = T4.employeeNumber INNER JOIN offices AS T5 ON T4.officeCode = T5.officeCode WHERE STRFTIME('%Y', T2.orderDate) = '2005' AND T4.jobTitle = 'Sales Rep' ORDER BY T1.quantityOrdered DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: What is the phone number of all companies where the last name of the contact person starts with the letter M and are not from Germany? [/INST]
SELECT phone FROM customers WHERE contactLastName LIKE 'M%' AND country != 'Germany';
[INST] Here is a database schema: payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Calculate the average amount of payments made by customers during the first half of 2004. [/INST]
SELECT AVG(amount) FROM payments WHERE paymentDate BETWEEN '2004-01-01' AND '2004-06-30';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: Of all the orders placed and shipped throughout the year 2005, what percentage of those orders corresponds to customer number 186? [/INST]
SELECT CAST(SUM(CASE WHEN customerNumber = 186 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(orderNumber) FROM orders WHERE status = 'Shipped' AND shippedDate BETWEEN '2005-01-01' AND '2005-12-31';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: How many customers with a canceled shipment have a credit limit greater than 115,000? [/INST]
SELECT COUNT(T1.customerNumber) FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.status = 'Cancelled' AND T1.creditLimit > 115000;
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: On what date did the customer with the lowest credit limit serviced by sales representative Barry Jones make payments for his/her orders? [/INST]
SELECT T3.paymentDate FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN payments AS T3 ON T2.customerNumber = T3.customerNumber WHERE T1.firstName = 'Barry' AND T1.lastName = 'Jones' AND T1.jobTitle = 'Sales Rep' ORDER BY T2.creditLimit ASC LIMIT 1;
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: To whom does the employee have to inform that is the sales representative of the French customer? [/INST]
SELECT T1.reportsTo FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber WHERE T2.country = 'France';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: What is the full address of the customer who commented that DHL be used for the order that was shipped on April 4, 2005? [/INST]
SELECT T1.addressLine1, T1.addressLine2 FROM customers AS T1 INNER JOIN orders AS T2 ON T1.customerNumber = T2.customerNumber WHERE T2.shippedDate = '2005-04-04' AND T2.status = 'Shipped';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: What is the full address of the office where the employee who is a sales representative for the customer whose business is located in the city of New York works? [/INST]
SELECT T2.addressLine1, T2.addressLine2 FROM employees AS T1 INNER JOIN customers AS T2 ON T1.employeeNumber = T2.salesRepEmployeeNumber INNER JOIN offices AS T3 ON T1.officeCode = T3.officeCode WHERE T2.city = 'NYC' AND T1.jobTitle = 'Sales Rep';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: What is the full address of the office where 4 people work and one of them is Sales Representation? [/INST]
SELECT T1.addressLine1, T1.addressLine2 FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T2.jobTitle = 'Sales Rep';
[INST] Here is a database schema: productlines : productLine [ TEXT ] primary_key textDescription [ TEXT ] htmlDescription [ TEXT ] image [ BLOB ] products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] Please write me a SQL statement that answers the following question: What profit can the seller Carousel DieCast Legends make from the sale of the product described as "The perfect holiday or anniversary gift for executives"? [/INST]
SELECT SUM(T2.MSRP - T2.buyPrice) FROM productlines AS T1 INNER JOIN products AS T2 ON T1.productLine = T2.productLine WHERE T2.productVendor = 'Carousel DieCast Legends' AND T1.textDescription LIKE '%perfect holiday or anniversary gift for executives%';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Of the clients whose businesses are located in the city of Boston, calculate which of them has a higher average amount of payment. [/INST]
SELECT T1.customerNumber FROM customers AS T1 INNER JOIN payments AS T2 ON T1.customerNumber = T2.customerNumber WHERE T1.city = 'Boston' GROUP BY T1.customerNumber ORDER BY SUM(T2.amount) / COUNT(T2.paymentDate) DESC LIMIT 1;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the total quantity ordered for 18th Century Vintage Horse Carriage and the average price. [/INST]
SELECT SUM(T2.quantityOrdered) , SUM(T2.quantityOrdered * T2.priceEach) / SUM(T2.quantityOrdered) FROM products AS T1 INNER JOIN orderdetails AS T2 ON T1.productCode = T2.productCode WHERE T1.productName = '18th Century Vintage Horse Carriage';
[INST] Here is a database schema: orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many kinds of products did order No. 10252 contain? [/INST]
SELECT COUNT(t.productCode) FROM orderdetails t WHERE t.orderNumber = '10252';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Who is the sales representative that made the order which was sent to 25 Maiden Lane, Floor No. 4? [/INST]
SELECT T2.firstName, T2.lastName FROM customers AS T1 INNER JOIN employees AS T2 ON T1.salesRepEmployeeNumber = T2.employeeNumber WHERE T1.addressLine1 = '25 Maiden Lane' AND T1.addressLine2 = 'Floor No. 4';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: Where's Foon Yue Tseng's office located at? Give the detailed address. [/INST]
SELECT T1.addressLine1, T1.addressLine2 FROM offices AS T1 INNER JOIN employees AS T2 ON T1.officeCode = T2.officeCode WHERE T2.firstName = 'Foon Yue' AND T2.lastName = 'Tseng';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Compared with the orders happened on 2005-04-08 and two days later, which day's order had a higher value? [/INST]
SELECT T2.orderDate FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE STRFTIME('%Y-%m-%d', T2.orderDate) = '2005-04-08' OR STRFTIME('%Y-%m-%d', T2.orderDate) = '2005-04-10' ORDER BY T1.quantityOrdered * T1.priceEach DESC LIMIT 1;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many products with the highest expected profits were sold in total? [/INST]
SELECT SUM(t2.quantityOrdered) FROM orderdetails AS t2 INNER JOIN ( SELECT t1.productCode FROM products AS t1 ORDER BY t1.MSRP - t1.buyPrice DESC LIMIT 1 ) AS t3 ON t2.productCode = t3.productCode;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: How much did Petit Auto pay on 2004-08-09? [/INST]
SELECT t1.amount FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Petit Auto' AND t1.paymentDate = '2004-08-09';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: What was the contact name for the check "NR157385"? [/INST]
SELECT t2.contactFirstName, t2.contactLastName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.checkNumber = 'NR157385';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: Which customer made the order No. 10160? Give the contact name. [/INST]
SELECT t2.contactFirstName, t2.contactLastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10160';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: Where was the order No. 10383 shipped to? Show me the address. [/INST]
SELECT t2.addressLine1, t2.addressLine2 FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.orderNumber = '10383';
[INST] Here is a database schema: productlines : productLine [ TEXT ] primary_key textDescription [ TEXT ] htmlDescription [ TEXT ] image [ BLOB ] products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] Please write me a SQL statement that answers the following question: For the productline where the product No.S18_2949 was produced, what's the text description for that product line? [/INST]
SELECT t1.textDescription FROM productlines AS t1 INNER JOIN products AS t2 ON t1.productLine = t2.productLine WHERE t2.productCode = 'S18_2949';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: If Dragon Souveniers, Ltd. aren't satisfied with their order and want to send a complain e-mail, which e-mail address should they send to? [/INST]
SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Dragon Souveniers, Ltd.';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: How many French customers does Gerard Hernandez take care of? [/INST]
SELECT COUNT(t1.customerNumber) FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.country = 'France' AND t2.firstName = 'Gerard' AND t2.lastName = 'Hernandez';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What was the latest order that customer No.114 made? Give the name of the product. [/INST]
SELECT t3.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t1.productCode = t3.productCode WHERE t2.customerNumber = '114' ORDER BY t2.orderDate DESC LIMIT 1;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: For the product No. S18_3482 in the Order No.10108, how much discount did the customer have? [/INST]
SELECT (t1.MSRP - t2.priceEach) / t1.MSRP FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productCode = 'S18_3482' AND t2.orderNumber = '10108';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: To whom does Steve Patterson report? Please give his or her full name. [/INST]
SELECT t2.firstName, t2.lastName FROM employees AS t1 INNER JOIN employees AS t2 ON t2.employeeNumber = t1.reportsTo WHERE t1.firstName = 'Steve' AND t1.lastName = 'Patterson';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: How do I contact the President of the company? [/INST]
SELECT t.email FROM employees t WHERE t.jobTitle = 'President';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Who is the sales representitive of Muscle Machine Inc? Please give the employee's full name. [/INST]
SELECT t2.firstName, t2.lastName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: If I'm from the Muscle Machine Inc, to which e-mail adress should I write a letter if I want to reach the superior of my sales representitive? [/INST]
SELECT t2.email FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t1.customerName = 'Muscle Machine Inc';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Please list all the customers that have Steve Patterson as their sales representitive. [/INST]
SELECT t1.customerName FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'Steve' AND t2.lastName = 'Patterson';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: How many customers have an employee who reports to William Patterson as their sales representitive? [/INST]
SELECT COUNT(t1.customerNumber) FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'William' AND t2.lastName = 'Patterson';
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Please list the phone numbers of the top 3 customers that have the highest credit limit and have Leslie Jennings as their sales representitive. [/INST]
SELECT t1.phone FROM customers AS t1 INNER JOIN employees AS t2 ON t1.salesRepEmployeeNumber = t2.employeeNumber WHERE t2.firstName = 'Leslie' AND t2.lastName = 'Jennings' ORDER BY t1.creditLimit DESC LIMIT 3;
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: How many sales representitives are based in the offices in the USA? [/INST]
SELECT COUNT(t1.employeeNumber) FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t2.country = 'USA' AND t1.jobTitle = 'Sales Rep';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: Where can I find the office of the President of the company? [/INST]
SELECT t2.addressLine1, t2.addressLine2 FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'President';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: What's the postal code of the office the VP Sales is at? [/INST]
SELECT t2.postalCode FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t1.jobTitle = 'VP Sales';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total price of the order made by Cruz & Sons Co. on 2003/3/3? [/INST]
SELECT SUM(t1.priceEach * t1.quantityOrdered) FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Which product did Cruz & Sons Co. order on 2003/3/3? [/INST]
SELECT t4.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode WHERE t3.customerName = 'Cruz & Sons Co.' AND t2.orderDate = '2003-03-03';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Which product did Cruz & Sons Co. ask for the biggest amount in a single order? [/INST]
SELECT t4.productName FROM orderdetails AS t1 INNER JOIN orders AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN customers AS t3 ON t2.customerNumber = t3.customerNumber INNER JOIN products AS t4 ON t1.productCode = t4.productCode WHERE t3.customerName = 'Cruz & Sons Co.' ORDER BY t1.priceEach * t1.quantityOrdered DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: When were the products ordered by Cruz & Sons Co. on 2003-03-03 shipped? [/INST]
SELECT t1.shippedDate FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.customerName = 'Cruz & Sons Co.' AND t1.orderDate = '2003-03-03';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the amount of customers of 1957 Chevy Pickup by customers in a month? [/INST]
SELECT COUNT(T2.customerNumber) FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.productCode IN ( SELECT productCode FROM products WHERE productName = '1957 Chevy Pickup' );
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] Please write me a SQL statement that answers the following question: Name the product from the 'Classic Cars' production line that has the greatest expected profit. [/INST]
SELECT t.productName, t.MSRP - t.buyPrice FROM products AS t WHERE t.productLine = 'Classic Cars' ORDER BY t.MSRP - t.buyPrice DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: List all the name of customers who have orders that are still processing. [/INST]
SELECT t2.customerName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t1.status = 'In Process';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Among all orders shipped, calculate the percentage of orders shipped at least 3 days before the required date. [/INST]
SELECT COUNT(CASE WHEN JULIANDAY(t1.shippeddate) - JULIANDAY(t1.requireddate) > 3 THEN T1.customerNumber ELSE NULL END) FROM orders AS T1 INNER JOIN orderdetails AS T2 ON T1.orderNumber = T2.orderNumber WHERE T1.status = 'Shipped';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: Find the customer who made the highest payment in 2005. [/INST]
SELECT t2.customerName FROM payments AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t1.paymentDate) = '2005' GROUP BY t2.customerNumber, t2.customerName ORDER BY SUM(t1.amount) DESC LIMIT 1;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Which is the most ordered quantity product? What is its expected profit margin per piece? [/INST]
SELECT productName, MSRP - buyPrice FROM products WHERE productCode = ( SELECT productCode FROM orderdetails ORDER BY quantityOrdered DESC LIMIT 1 );
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: For the order has the most product ordered, name the customer who placed the order. [/INST]
SELECT T2.firstName, T2.lastName FROM offices AS T1 INNER JOIN employees AS T2 ON T1.officeCode = T2.officeCode WHERE T2.employeeNumber = ( SELECT MAX(employeeNumber) FROM employees );
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: List all customer names with orders that are disputed. [/INST]
SELECT t3.firstName, t3.lastName FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN employees AS t3 ON t2.salesRepEmployeeNumber = t3.employeeNumber WHERE t1.status = 'Disputed';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: What is the percentage of employees are in Paris office? [/INST]
SELECT CAST(COUNT(CASE WHEN t1.city = 'Paris' THEN t2.employeeNumber ELSE NULL END) AS REAL) * 100 / COUNT(t2.employeeNumber) FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode;
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: Name the Sales Manager of Europe, Middle East, and Africa region. In which office does he/she report to? [/INST]
SELECT t2.firstName, t2.lastName FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode WHERE t2.jobTitle = 'Sale Manager (EMEA)';
[INST] Here is a database schema: offices : officeCode [ TEXT ] primary_key city [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] state [ TEXT ] country [ TEXT ] postalCode [ TEXT ] territory [ TEXT ] employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] Please write me a SQL statement that answers the following question: List the name of employees in Japan office and who are they reporting to. [/INST]
SELECT t2.firstName, t2.lastName, t2.reportsTo FROM offices AS t1 INNER JOIN employees AS t2 ON t1.officeCode = t2.officeCode WHERE t1.country = 'Japan';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Which customer ordered 1939 'Chevrolet Deluxe Coupe' at the highest price? [/INST]
SELECT t4.customerName FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode INNER JOIN orders AS t3 ON t2.orderNumber = t3.orderNumber INNER JOIN customers AS t4 ON t3.customerNumber = t4.customerNumber WHERE t1.productName = '1939 Chevrolet Deluxe Coupe' ORDER BY t2.priceEach DESC LIMIT 1;
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of the payment amount in 2004 was made by Atelier graphique? [/INST]
SELECT SUM(CASE WHEN t1.customerName = 'Atelier graphique' THEN t2.amount ELSE 0 END) * 100 / SUM(t2.amount) FROM customers AS t1 INNER JOIN payments AS t2 ON t1.customerNumber = t2.customerNumber WHERE STRFTIME('%Y', t2.paymentDate) = '2004';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the actual profit for order number 10100. [/INST]
SELECT SUM((t1.priceEach - t2.buyPrice) * t1.quantityOrdered) FROM orderdetails AS t1 INNER JOIN products AS t2 ON t1.productCode = t2.productCode WHERE t1.orderNumber = '10100';
[INST] Here is a database schema: payments : customerNumber [ INTEGER ] payments.customerNumber = customers.customerNumber checkNumber [ TEXT ] paymentDate [ DATE ] amount [ REAL ] Please write me a SQL statement that answers the following question: How much did customer 103 pay in total? [/INST]
SELECT SUM(t.amount) FROM payments t WHERE t.customerNumber = '103';
[INST] Here is a database schema: orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total price of the order 10100? [/INST]
SELECT SUM(t.priceEach * t.quantityOrdered) FROM orderdetails t WHERE t.orderNumber = '10100';
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the top three product names with the highest unit price. [/INST]
SELECT t1.productName FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode ORDER BY t2.priceEach DESC LIMIT 3;
[INST] Here is a database schema: employees : employeeNumber [ INTEGER ] primary_key lastName [ TEXT ] firstName [ TEXT ] extension [ TEXT ] email [ TEXT ] officeCode [ TEXT ] employees.officeCode = offices.officeCode reportsTo [ INTEGER ] employees.reportsTo = employees.employeeNumber jobTitle [ TEXT ] customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] Please write me a SQL statement that answers the following question: Among the customers of empolyee 1370, who has the highest credit limit?Please list the full name of the contact person. [/INST]
SELECT t2.contactFirstName, t2.contactLastName FROM employees AS t1 INNER JOIN customers AS t2 ON t1.employeeNumber = t2.salesRepEmployeeNumber WHERE t1.employeeNumber = '1370' ORDER BY t2.creditLimit DESC LIMIT 1;
[INST] Here is a database schema: products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many 2003 Harley-Davidson Eagle Drag Bikes were ordered? [/INST]
SELECT SUM(t2.quantityOrdered) FROM products AS t1 INNER JOIN orderdetails AS t2 ON t1.productCode = t2.productCode WHERE t1.productName = '2003 Harley-Davidson Eagle Drag Bike';
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: When was the product with the highest unit price shipped? [/INST]
SELECT t1.shippedDate FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber ORDER BY t2.priceEach DESC LIMIT 1;
[INST] Here is a database schema: orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber products : productCode [ TEXT ] primary_key productName [ TEXT ] productLine [ TEXT ] products.productLine = productlines.productLine productScale [ TEXT ] productVendor [ TEXT ] productDescription [ TEXT ] quantityInStock [ INTEGER ] buyPrice [ REAL ] MSRP [ REAL ] orderdetails : orderNumber [ INTEGER ] productCode [ TEXT ] quantityOrdered [ INTEGER ] priceEach [ REAL ] orderLineNumber [ INTEGER ] Please write me a SQL statement that answers the following question: How many motorcycles have been ordered in 2004? [/INST]
SELECT SUM(t2.quantityOrdered) FROM orders AS t1 INNER JOIN orderdetails AS t2 ON t1.orderNumber = t2.orderNumber INNER JOIN products AS t3 ON t2.productCode = t3.productCode WHERE t3.productLine = 'motorcycles' AND STRFTIME('%Y', t1.orderDate) = '2004';
[INST] Here is a database schema: customers : customerNumber [ INTEGER ] primary_key customerName [ TEXT ] contactLastName [ TEXT ] contactFirstName [ TEXT ] phone [ TEXT ] addressLine1 [ TEXT ] addressLine2 [ TEXT ] city [ TEXT ] state [ TEXT ] postalCode [ TEXT ] country [ TEXT ] salesRepEmployeeNumber [ INTEGER ] customers.salesRepEmployeeNumber = employees.employeeNumber creditLimit [ REAL ] orders : orderNumber [ INTEGER ] primary_key orderDate [ DATE ] requiredDate [ DATE ] shippedDate [ DATE ] status [ TEXT ] comments [ TEXT ] customerNumber [ INTEGER ] orders.customerNumber = customers.customerNumber Please write me a SQL statement that answers the following question: Please list the order number of the customer whose credit card has a limit of 45300. [/INST]
SELECT t1.orderNumber FROM orders AS t1 INNER JOIN customers AS t2 ON t1.customerNumber = t2.customerNumber WHERE t2.creditLimit = 45300;