Chinastark/bird_dataset huggingface dataset:
Database: car_retails
Note: Sales Rep is a job title; Tokyo is a city; full name = firstname+lastname;
Question: How many Sales Rep who are working in Tokyo? List out email and full name of those employees.
SQL: SELECT employees.firstname, employees.lastname, employees.email FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'Tokyo' AND employees.jobtitle = 'Sales Rep'
Database: car_retails
Note: staff of refers to reportsto; San Francisco is a city;
Question: State the email of those who are staff of Murphy Diane whose number is 1002 and living in San Francisco
SQL: SELECT employees.email FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE employees.reportsto = 1002 AND offices.city = 'San Francisco'
Database: car_retails
Note: code of employee refers to employeenumber; United states of America refers to country = 'USA';
Question: Determine the email and Code of employee who are working at United State, state MA
SQL: SELECT employees.email, employees.employeenumber FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.state = 'MA' AND offices.country = 'USA'
Database: car_retails
Note: Sales Manager is a job title; Sydney is a city;
Question: How many Sales Manager who are working in Sydney? List out their email.
SQL: SELECT employees.email FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE employees.jobtitle LIKE '%Sales Manager%' AND offices.city = 'Sydney'
Database: car_retails
Note: Australia is a country; creditlimit < 20000;
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.
SQL: SELECT employees.email, offices.country FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.country = 'Australia' AND customers.creditlimit < 200000 AND employees.jobtitle = 'Sales Rep'
Database: car_retails
Note: UK is a country; Sales Rep is a job title;
Question: State 10 emails of UK Sales Rep who have the lowest credit limit.
SQL: SELECT DISTINCT employees.email FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.jobtitle = 'Sales Rep' AND customers.country = 'UK' ORDER BY customers.creditlimit LIMIT 10
Database: car_retails
Note: Australian is a nationality of country = 'Australia'; credit line refers to creditlimit; creditlimit < 220000;
Question: How many Australian customers who have credit line under 220000?
SQL: SELECT count(creditlimit) FROM customers WHERE creditlimit < 220000 AND country = 'Australia'
Database: car_retails
Note: amount of payment refers to amount;
Question: List out 3 customer numbers who have highest amount payment
SQL: SELECT customernumber FROM payments ORDER BY amount DESC LIMIT 3
Database: car_retails
Note: United states of America refers to country = 'USA'; code of employee refers to employeenumber;
Question: Determine the email and Code of employee who are working at United State, state CA
SQL: SELECT employees.email, employees.employeenumber FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.country = 'USA' AND offices.state = 'CA' GROUP BY employees.email, employees.officecode
Database: car_retails
Note: full name = contactfirstname, contactlastname; Boston is a city;
Question: List out full name of employees who are working in Boston?
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'Boston'
Database: car_retails
Note: UK is a country; Sales Rep is a job title;
Question: State top 3 emails of UK Sales Rep who have the highest credit limit.
SQL: SELECT employees.email FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.jobtitle = 'Sales Rep' AND customers.country = 'UK' GROUP BY customers.customername, employees.email ORDER BY sum(customers.creditlimit) DESC LIMIT 3
Database: car_retails
Note: Norway is a country; credit line refers to creditlimit; creditlimit<220000;
Question: How many customers who are in Norway and have credit line under 220000?
SQL: SELECT count(creditlimit) FROM customers WHERE creditlimit < 220000 AND country = 'Norway'
Database: car_retails
Note: full name = firstname+lastname; Paris is a city;
Question: List out full name and email of employees who are working in Paris?
SQL: SELECT employees.firstname, employees.lastname, employees.email FROM employees INNER JOIN offices ON employees.officecode = offices.officecode WHERE offices.city = 'Paris'
Database: car_retails
Note: motorcycle is a product line;
Question: List the product code of the top five motorcycles, by descending order, the number of quantity in stock.
SQL: SELECT productcode, quantityinstock FROM products WHERE productline = 'Motorcycles' ORDER BY quantityinstock DESC LIMIT 5
Database: car_retails
Note: German is a nationality of country = 'Germany'; creditlimit = 0;
Question: Among the German customers, how many of the them has credit limit of zero?
SQL: SELECT count(customernumber) FROM customers WHERE creditlimit = 0 AND country = 'Germany'
Database: car_retails
Note: paymentdate BETWEEN '2003-01-01' AND '2004-12-31'; customers who have paid more than three times refers to (COUNT(customernumber)>3);
Question: From 2003 to 2004, how many customers have paid more than three times?
SQL: 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
Database: car_retails
Note: average actual profit = AVG(SUBTRACT(priceeach, buyprice)); 1937 Lincoln Berline is a product name;
Question: What is the average actual profit by 1937 Lincoln Berline?
SQL: SELECT sum(orderdetails.priceeach - products.buyprice) / count(*) FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode WHERE products.productname = '1937 Lincoln Berline'
Database: car_retails
Note: motorcycle is a product line; American is a nationality of country = 'USA';
Question: Among the motorcycles with product scale of 1:10, which of them is the most ordered by American customers?
SQL: SELECT products.productname FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE products.productline = 'Motorcycles' AND products.productscale = '1:10' AND customers.country = 'USA' GROUP BY products.productname ORDER BY sum(orderdetails.quantityordered) DESC LIMIT 1
Database: car_retails
Note: paymentdate BETWEEN '2003-08-01' AND '2004-08-30'; Mini Gifts Distributors Ltd. Is a customer name;
Question: Between 8/1/2003 and 8/30/2004, how many checks were issued by Mini Gifts Distributors Ltd.? Please list their check numbers.
SQL: SELECT payments.checknumber FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE payments.paymentdate >= '2003-08-01' AND payments.paymentdate <= '2004-08-30' AND customers.customername = 'Mini Gifts Distributors Ltd.'
Database: car_retails
Note: plane is a product line; total price = MULTIPLY(quantityordered, priceeach); how much the total price exceeds the average = SUBTRACT(MAX(MULTIPLY(quantityordered, priceeach))), AVG(priceeach));
Question: For the planes which has the hightest total price, how much it exceeds the average?
SQL: SELECT max(quantityordered * priceeach) - avg(priceeach) FROM orderdetails WHERE productcode IN ( SELECT productcode FROM products WHERE productline = 'Planes' )
Database: car_retails
Note: total value = SUM(MULTIPLY(quantityordered, priceeach)); shipped orders refers to status = 'Shipped'; vintage car is a product line; year(orderdate) between 2003 and 2004;
Question: What is the total value of shipped vintage car orders from 2003-2004?
SQL: SELECT sum(orderdetails.priceeach * orderdetails.quantityordered) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE orders.status = 'Shipped' AND orders.orderdate BETWEEN '2003-01-01' AND '2004-12-31'
Database: car_retails
Note: payment refers to amount; full name = firstname+lastname; supervisor refers to reportsto; 'reportsto' is the leader of the 'employeenumber';
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.
SQL: SELECT employees.firstname, employees.lastname, employees.reportsto FROM employees INNER JOIN customers ON employees.employeenumber = customers.salesrepemployeenumber INNER JOIN payments ON customers.customernumber = payments.customernumber ORDER BY payments.amount DESC LIMIT 1
Database: car_retails
Note: Boston is a city; amount of order = MULTIPLY(quantityordered, priceeach);
Question: What is the highest amount of order made by the sales representative in Boston? Please give the name of the product and amount.
SQL: SELECT products.productname, orderdetails.quantityordered * orderdetails.priceeach FROM orderdetails INNER JOIN products ON orderdetails.productcode = products.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE customers.city = 'Boston' AND customers.salesrepemployeenumber IN ( SELECT employeenumber FROM employees WHERE jobtitle = 'Sales Rep' ) ORDER BY orderdetails.quantityordered DESC LIMIT 1
Database: car_retails
Note: total actual profit = SUM(SUBTRACT(priceeach, buyprice)); American is a nationality of country = 'USA'; orderdate BETWEEN '2003-01-06' AND '2005-05-09';
Question: What is the total actual profit gained from orders made by American customers from 2003-01-06 to 2005-05-09?
SQL: SELECT sum(orderdetails.priceeach - products.buyprice) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.orderdate > '2003-01-05' AND orders.orderdate < '2005-05-10'
Database: car_retails
Note: orderdate between '2005-01-01' and '2005-12-31'; full address = addressline1+addressline2;
Question: From which branch does the sales representative employee who made the most sales in 2005? Please indicates its full address and phone number.
SQL: SELECT customers.addressline1, customers.addressline2, customers.phone FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN customers ON orders.customernumber = customers.customernumber INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber INNER JOIN offices ON employees.officecode = offices.officecode WHERE strftime('%Y', orders.orderdate) = '2005' AND employees.jobtitle = 'Sales Rep' ORDER BY orderdetails.quantityordered DESC LIMIT 1
Database: car_retails
Note: last name of contact person starts with M refers to lastname LIKE 'M%'; Germany is a country; not from Germany refers to country<>'Germany';
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?
SQL: SELECT phone FROM customers WHERE contactlastname LIKE 'M%' AND country != 'Germany'
Database: car_retails
Note: average amount of payments = DIVIDE(SUM(amount), COUNT(customernumber); first half of 2014 refers to paymentdate >= '2004-01-01' AND paymentdate < '2004-07-01;
Question: Calculate the average amount of payments made by customers during the first half of 2004.
SQL: SELECT avg(amount) FROM payments WHERE paymentdate BETWEEN '2004-01-01' AND '2004-06-30'
Database: car_retails
Note: shipped orders refers to status = 'shipped'; year(shippeddate) = 2005; percentage = DIVIDE(SUM(customernumber = 186)), COUNT(ordernumber)) as percentage;
Question: Of all the orders placed and shipped throughout the year 2005, what percentage of those orders corresponds to customer number 186?
SQL: 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'
Database: car_retails
Note: cancelled shipment refers to status = 'cancelled'; creditlimit > 115000;
Question: How many customers with a canceled shipment have a credit limit greater than 115,000?
SQL: SELECT count(customers.customernumber) FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber WHERE orders.status = 'Cancelled' AND customers.creditlimit > 115000
Database: car_retails
Question: On what date did the customer with the lowest credit limit serviced by sales representative Barry Jones make payments for his/her orders?
SQL: SELECT payments.paymentdate FROM employees INNER JOIN customers ON employees.employeenumber = customers.salesrepemployeenumber INNER JOIN payments ON customers.customernumber = payments.customernumber WHERE employees.firstname = 'Barry' AND employees.lastname = 'Jones' AND employees.jobtitle = 'Sales Rep' ORDER BY customers.creditlimit ASC LIMIT 1
Database: car_retails
Note: inform refers to reportsto; 'reportsto' is the leader of the 'employeenumber'; France is a country; country = 'France';
Question: To whom does the employee have to inform that is the sales representative of the French customer?
SQL: SELECT employees.reportsto FROM employees INNER JOIN customers ON employees.employeenumber = customers.salesrepemployeenumber WHERE customers.country = 'France'
Database: car_retails
Note: full address = addressline1+addressline2; shippeddate = '2005-04-04';
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?
SQL: SELECT customers.addressline1, customers.addressline2 FROM customers INNER JOIN orders ON customers.customernumber = orders.customernumber WHERE orders.shippeddate = '2005-04-04' AND orders.status = 'Shipped'
Database: car_retails
Note: full address = addressline1 + addressline2; NYC is a shortname of New York city.;
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?
SQL: SELECT customers.addressline1, customers.addressline2 FROM employees INNER JOIN customers ON employees.employeenumber = customers.salesrepemployeenumber INNER JOIN offices ON employees.officecode = offices.officecode WHERE customers.city = 'NYC' AND employees.jobtitle = 'Sales Rep'
Database: car_retails
Note: full address = addressline1+addressline2; Sales Manager is a job title;
Question: What is the full address of the office where 4 people work and one of them is Sales Representation?
SQL: SELECT customers.addressline1, customers.addressline2 FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.jobtitle = 'Sales Rep'
Database: car_retails
Note: seller and product vendor are synonyms; Carousel DieCast Legends is a product vendor; profit = SUM(SUBTRACT(msrp, buyprice));
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"?
SQL: SELECT sum(products.msrp - products.buyprice) FROM productlines INNER JOIN products ON productlines.productline = products.productline WHERE products.productvendor = 'Carousel DieCast Legends' AND productlines.textdescription LIKE '%perfect holiday or anniversary gift for executives%'
Database: car_retails
Note: average amount payment = AVG(amount);
Question: Of the clients whose businesses are located in the city of Boston, calculate which of them has a higher average amount of payment.
SQL: SELECT customers.customernumber FROM customers INNER JOIN payments ON customers.customernumber = payments.customernumber WHERE customers.city = 'Boston' GROUP BY customers.customernumber ORDER BY sum(payments.amount) / count(payments.paymentdate) DESC LIMIT 1
Database: car_retails
Note: 18th Century Vintage Horse Carriage is a product name; average price = AVG(priceeach);
Question: Calculate the total quantity ordered for 18th Century Vintage Horse Carriage and the average price.
SQL: SELECT sum(orderdetails.quantityordered) , sum(orderdetails.quantityordered * orderdetails.priceeach) / sum(orderdetails.quantityordered) FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode WHERE products.productname = '18th Century Vintage Horse Carriage'
Database: car_retails
Note: products refer to productcode;
Question: How many kinds of products did order No. 10252 contain?
SQL: SELECT count(t.productcode) FROM orderdetails t WHERE t.ordernumber = '10252'
Database: car_retails
Note: Sales representative is an employee;
Question: Who is the sales representative that made the order which was sent to 25 Maiden Lane, Floor No. 4?
SQL: SELECT employees.firstname, employees.lastname FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE customers.addressline1 = '25 Maiden Lane' AND customers.addressline2 = 'Floor No. 4'
Database: car_retails
Note: Detailed address comprises addressline1 and addressline2;
Question: Where's Foon Yue Tseng's office located at? Give the detailed address.
SQL: SELECT offices.addressline1, offices.addressline2 FROM offices INNER JOIN employees ON offices.officecode = employees.officecode WHERE employees.firstname = 'Foon Yue' AND employees.lastname = 'Tseng'
Database: car_retails
Note: 2005-04-08 and two days later refer to orderdate = '2005-04-08' and orderdate = '2005-04-10'; order with a higher value refers to MAX(Total price) = MULTIPLY(quantityordered, priceeach);
Question: Compared with the orders happened on 2005-04-08 and two days later, which day's order had a higher value?
SQL: SELECT orders.orderdate FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber WHERE strftime('%Y-%m-%d', orders.orderdate) = '2005-04-08' OR strftime('%Y-%m-%d', orders.orderdate) = '2005-04-10' ORDER BY orderdetails.quantityordered * orderdetails.priceeach DESC LIMIT 1
Database: car_retails
Note: products refer to productcode; Expected profits = SUBTRACT(msrp, buyprice);
Question: How many products with the highest expected profits were sold in total?
SQL: SELECT sum(orderdetails.quantityordered) FROM orderdetails INNER JOIN ( SELECT products.productcode FROM products ORDER BY products.msrp - products.buyprice DESC LIMIT 1 ) AS t3 ON orderdetails.productcode = t3.productcode
Database: car_retails
Note: Petit Auto is name of customer; paymentdate = '2004-08-09';
Question: How much did Petit Auto pay on 2004-08-09?
SQL: SELECT payments.amount FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE customers.customername = 'Petit Auto' AND payments.paymentdate = '2004-08-09'
Database: car_retails
Note: Contact name refers to customername;
Question: What was the contact name for the check "NR157385"?
SQL: SELECT customers.contactfirstname, customers.contactlastname FROM payments INNER JOIN customers ON payments.customernumber = customers.customernumber WHERE payments.checknumber = 'NR157385'
Database: car_retails
Question: Which customer made the order No. 10160? Give the contact name.
SQL: SELECT customers.contactfirstname, customers.contactlastname FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.ordernumber = '10160'
Database: car_retails
Note: Address comprises addressline1 and addressline2;
Question: Where was the order No. 10383 shipped to? Show me the address.
SQL: SELECT customers.addressline1, customers.addressline2 FROM orders INNER JOIN customers ON orders.customernumber = customers.customernumber WHERE orders.ordernumber = '10383'
Database: car_retails
Question: For the productline where the product No.S18_2949 was produced, what's the text description for that product line?
SQL: SELECT productlines.textdescription FROM productlines INNER JOIN products ON productlines.productline = products.productline WHERE products.productcode = 'S18_2949'
Database: car_retails
Note: E-mail address belongs to employee; customername = 'Dragon Souveniers, Ltd.';
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?
SQL: SELECT employees.email FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE customers.customername = 'Dragon Souveniers, Ltd.'
Database: car_retails
Note: Gerakd Hermandez is an employee; French customer refers to customer from France where country = 'France';
Question: How many French customers does Gerard Hernandez take care of?
SQL: SELECT count(customers.customernumber) FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE customers.country = 'France' AND employees.firstname = 'Gerard' AND employees.lastname = 'Hernandez'
Database: car_retails
Note: The latest refers to the most recent orderdate;
Question: What was the latest order that customer No.114 made? Give the name of the product.
SQL: SELECT products.productname FROM orderdetails INNER JOIN orders ON orderdetails.ordernumber = orders.ordernumber INNER JOIN products ON orderdetails.productcode = products.productcode WHERE orders.customernumber = '114' ORDER BY orders.orderdate DESC LIMIT 1
Database: car_retails
Note: DIVIDE(SUBTRACT(msrp, priceeach)), msrp); product No. S18_3482 refers to productcode = 'S18_3482';
Question: For the product No. S18_3482 in the Order No.10108, how much discount did the customer have?
SQL: SELECT (products.msrp - orderdetails.priceeach) / products.msrp FROM products INNER JOIN orderdetails ON products.productcode = orderdetails.productcode WHERE products.productcode = 'S18_3482' AND orderdetails.ordernumber = '10108'
Database: car_retails
Note: reportsto' is the leader of the 'employeenumber';
Question: To whom does Steve Patterson report? Please give his or her full name.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN employees ON employees.employeenumber = employees.reportsto WHERE employees.firstname = 'Steve' AND employees.lastname = 'Patterson'
Database: car_retails
Note: President refers to the jobtitle;
Question: How do I contact the President of the company?
SQL: SELECT t.email FROM employees t WHERE t.jobtitle = 'President'
Database: car_retails
Note: Sales representative refers to jobtitle = 'Sales Rep'; Muscle Machine Inc is name of customer;
Question: Who is the sales representitive of Muscle Machine Inc? Please give the employee's full name.
SQL: SELECT employees.firstname, employees.lastname FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE customers.customername = 'Muscle Machine Inc'
Database: car_retails
Note: Muscle Machine Inc is name of customer; superior refers to 'reportsto', who is the leader of the 'employeenumber';
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?
SQL: SELECT employees.email FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE customers.customername = 'Muscle Machine Inc'
Database: car_retails
Note: Steve Patterson is an employee;
Question: Please list all the customers that have Steve Patterson as their sales representitive.
SQL: SELECT customers.customername FROM customers INNER JOIN employees ON customers.salesrepemployeenumber = employees.employeenumber WHERE employees.firstname = 'Steve' AND employees.lastname = 'Patterson'