Chinastark/bird_dataset huggingface dataset:
Database: sales
Note: name of the sales person = firstname, middleinitial, lastname; 'Road-250 Black, 48' is name of product;
Question: Name the sales person who helped Elizabeth A. White to purchase Road-250 Black, 48.
SQL: SELECT DISTINCT employees.firstname, employees.middleinitial, employees.lastname FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN employees ON sales.salespersonid = employees.employeeid INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.middleinitial = 'A' AND customers.lastname = 'White' AND products.name = 'Road-250 Black, 48' AND customers.firstname = 'Elizabeth'
Database: sales
Note: Headlights - Weatherproof' is name of product;
Question: How many sales people managed to sell Headlights - Weatherproof?
SQL: SELECT count(sales.salespersonid) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name = 'Headlights - Weatherproof'
Database: sales
Note: revenue = MULTIPLY(SUM(quantity, price)); 'HL Road Frame - Red, 56' is name of product;
Question: Calculate the revenue produced through sales of HL Road Frame - Red, 56.
SQL: SELECT sum(sales.quantity * products.price) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name = 'HL Road Frame - Red, 56'
Database: sales
Note: sales transactions refers to salesid;
Question: How many sales transactions were given by the customer named Joe L. Lopez?
SQL: SELECT count(sales.salesid) FROM sales INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Joe' AND customers.middleinitial = 'L' AND customers.lastname = 'Lopez'
Database: sales
Note: name of the customer = firstname, middleinitial, lastname; 'Touring Rim' is name of product;
Question: Name the customers who received 'Touring Rim' as a free gift.
SQL: SELECT DISTINCT customers.firstname, customers.middleinitial, customers.lastname FROM customers INNER JOIN sales ON customers.customerid = sales.customerid INNER JOIN products ON sales.productid = products.productid WHERE products.name = 'Touring Rim' AND products.price = 0
Database: sales
Question: Find the number of customers handled by each of the sales people.
SQL: SELECT count(customerid) FROM sales GROUP BY salespersonid
Database: sales
Question: How many sales people are handling all the customers?
SQL: SELECT count(employeeid) FROM employees
Database: sales
Note: name of the sales person = firstname, middleinitial, lastname;
Question: Identify the name of the sales person with employee ID 7.
SQL: SELECT firstname, middleinitial, lastname FROM employees WHERE employeeid = 7
Database: sales
Note: most expensive product refers to MAX(price); least expensive product refers to MIN(price); excluding free gifts refers to not including price = 0;
Question: Name the most expensive and the least expensive products available, excluding free gifts.
SQL: SELECT name FROM products WHERE price IN (( SELECT max(price) FROM products ), ( SELECT min(price) FROM products ))
Database: sales
Note: ML Bottom Bracket' is name of product; percentage = MULTIPLY(DIVIDE(SUM(customerid WHERE firstname = 'Albert' AND middleinitial = 'I' AND lastname = 'Ringer'), COUNT(customerid)), 1.0);
Question: Among all the customers who have purchased ML Bottom Bracket, identify the percentage of sales by Albert I. Ringer?
SQL: SELECT cast(sum(iif(employees.firstname = 'Albert' AND employees.middleinitial = 'I' AND employees.lastname = 'Ringer', 1, 0)) AS REAL) * 100 / count(sales.customerid) FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN employees ON sales.salespersonid = employees.employeeid WHERE products.name = 'ML Bottom Bracket'
Database: sales
Question: How many customers have the first name Abigail?
SQL: SELECT count(customerid) FROM customers WHERE firstname = 'Abigail'
Database: sales
Note: Blade' is name of product;
Question: Indicate the quantity of Blade products sold.
SQL: SELECT DISTINCT sales.quantity FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name = 'Blade'
Database: sales
Note: full name of the employee = firstname, lastname; most quantity refers to MAX(quantity);
Question: Give the full name of the employee who has sold the most quantity.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: full name of the customer = firstname, lastname; most quantity refers to MAX(quantity);
Question: List the full name of the customer who purchased the most quantity of products.
SQL: SELECT customers.firstname, customers.lastname FROM customers INNER JOIN sales ON customers.customerid = sales.customerid ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: most sold refers to MAX(quantity);
Question: What is the name of the product that is most sold by sale person id 20?
SQL: SELECT products.name FROM products INNER JOIN sales ON products.productid = sales.productid WHERE sales.salespersonid = 20 ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: trading quantity for more than 500 refers to quantity > 500;
Question: List the first names of employees with trading quantity for more than 500.
SQL: SELECT DISTINCT employees.firstname FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid WHERE sales.quantity > 500
Database: sales
Question: List the first names of customers who have purchased products from sale person id 1.
SQL: SELECT customers.firstname FROM customers INNER JOIN sales ON customers.customerid = sales.customerid WHERE sales.salespersonid = 1
Database: sales
Note: total trading quantity = SUM(quantity WHERE employees.firstname = 'Abraham' AND customers.firstname = 'Aaron' AND customers.lastname = 'Alexander');
Question: Calculate the total trading quantity of Abraham sold to Aaron Alexander.
SQL: SELECT sum(sales.quantity) FROM customers INNER JOIN sales ON customers.customerid = sales.customerid INNER JOIN employees ON sales.salespersonid = employees.employeeid WHERE sales.salespersonid = 1 AND customers.firstname = 'Aaron' AND customers.lastname = 'Alexander' AND employees.firstname = 'Abraham'
Database: sales
Note: full names of customers = firstname, lastname; quantity over 600 refers to quantity > 600;
Question: List the full names of customers who have purchased products in quantity over 600.
SQL: SELECT customers.firstname, customers.lastname FROM customers INNER JOIN sales ON customers.customerid = sales.customerid WHERE sales.quantity > 600
Database: sales
Note: most quantity refers to MAX(quantity); who refers to firstname, lastname;
Question: Among the customers whose first name is Cameron, who bought the product in the most quantity?
SQL: SELECT customers.firstname, customers.lastname FROM customers INNER JOIN sales ON customers.customerid = sales.customerid WHERE customers.firstname = 'Cameron' ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: price greater than 100 refers to price > 100;
Question: Please provide sales ID for products named Hex Nut with a price greater than 100.
SQL: SELECT sales.salesid FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name LIKE 'Hex Nut%' AND products.price > 100
Database: sales
Note: priced from 1000 to 2000 refers to price BETWEEN 1000 AND 2000;
Question: Identify customer IDs who bought products priced from 1000 to 2000.
SQL: SELECT DISTINCT sales.customerid FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.price BETWEEN 1000 AND 2000
Database: sales
Note: total quantity = SUM(quantity); gifts refers to price = 0;
Question: Calculate the total quantity of products that are gifts.
SQL: SELECT sum(sales.quantity) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.price = 0
Database: sales
Note: percentage = MULTIPLY(DIVIDE(SUM(quantity WHERE price = 0), SUM(quantity)), 1.0); gift products refers to price = 0;
Question: Calculate the quantity percentage of the gift products in the total trading quantity.
SQL: SELECT cast(sum(iif(products.price = 0, sales.quantity, 0)) AS REAL) * 100 / sum(sales.quantity)FROM products INNER JOIN sales ON products.productid = sales.productid
Database: sales
Note: percentage = MULTIPLY(DIVIDE(SUM(quantity WHERE name = 'Blade'), SUM(quantity)), 1.0); 'blades' refers to name of product;
Question: Calculate the percentage of sold blades in the total number of transactions.
SQL: SELECT cast(sum(iif(products.name = 'Blade', sales.quantity, 0)) AS REAL) * 100 / sum(sales.quantity) FROM products INNER JOIN sales ON products.productid = sales.productid
Database: sales
Question: How many of the employees have the last name "Ringer" ?
SQL: SELECT count(lastname) FROM employees WHERE lastname = 'Ringer'
Database: sales
Note: product ID lower than 15 refers to productid < 15; costs 10 and below refers to price; price <= 10;
Question: Among the products with product ID lower than 15, how many of them costs 10 and below?
SQL: SELECT count(productid) FROM products WHERE productid < 15 AND price <= 10
Database: sales
Question: Give the product's name brought by Aaron Alexander.
SQL: SELECT DISTINCT products.name FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Aaron' AND customers.lastname = 'Alexander'
Database: sales
Note: highest prices refers to MAX(price); quantity ranges from 400 to 500 refers to quantity BETWEEN 400 AND 500;
Question: Give the product ID and name of the product with the highest prices among the quantity ranges from 400 to 500.
SQL: SELECT products.productid, products.name FROM products INNER JOIN sales ON products.productid = sales.productid WHERE sales.quantity BETWEEN 400 AND 500 ORDER BY products.price DESC LIMIT 1
Database: sales
Note: highest quantity refers to MAX(quantity);
Question: Among customers named Kate, who has the highest quantity?
SQL: SELECT customers.firstname, customers.lastname FROM sales INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Kate' ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: price ranges from 100 to 150 refers to price BETWEEN 100 AND 150; quantity lower than 25 refers to quantity < 25;
Question: Among the products that have price ranges from 100 to 150, what is the customer ID and sales ID of the product with a quantity lower than 25?
SQL: SELECT sales.customerid, sales.salesid FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.price BETWEEN 100 AND 150 AND sales.quantity < 25
Database: sales
Question: List the quantity and price of the product bought by Abigail Henderson.
SQL: SELECT sales.quantity, products.price FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Abigail' AND customers.lastname = 'Henderson'
Database: sales
Question: In sales with a quantity of 60, how many of them have a price not greater than 500?
SQL: SELECT count(products.productid) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE sales.quantity = 60 AND products.price <= 500
Database: sales
Note: quantity below 200 refers to quantity < 200;
Question: In customers with the first name of Erica, how many of them bought a quantity below 200?
SQL: SELECT count(sales.productid) FROM sales INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Erica' AND sales.quantity < 200
Database: sales
Note: highest quantity refers to MAX(quantity);
Question: Among products bought by Kathryn Ashe, what is the name of the product with the highest quantity?
SQL: SELECT products.name FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN customers ON sales.customerid = customers.customerid WHERE customers.firstname = 'Kathryn' AND customers.lastname = 'Ashe' ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Question: What is the price and quantity of the product named Seat Tube?
SQL: SELECT DISTINCT products.price, sales.quantity FROM sales INNER JOIN products ON sales.productid = products.productid WHERE products.name = 'Seat Tube'
Database: sales
Question: What is the price and name of the product bought by Erica Xu?
SQL: SELECT products.price, products.name FROM sales INNER JOIN customers ON sales.customerid = customers.customerid INNER JOIN products ON sales.productid = products.productid WHERE customers.firstname = 'Erica' AND customers.lastname = 'Xu'
Database: sales
Note: External Lock Washer 7' is name of product;
Question: List the sales ID of the product with a quantity of 590 and named "External Lock Washer 7".
SQL: SELECT sales.salesid FROM sales INNER JOIN products ON sales.productid = products.productid WHERE products.name = 'External Lock Washer 7' AND sales.quantity = 590
Database: sales
Note: who refers to firstname, lastname;
Question: In sales ID between 30 and 40, who is the customer that bought a total quantity of 403?
SQL: SELECT customers.firstname, customers.lastname FROM sales INNER JOIN customers ON sales.customerid = customers.customerid WHERE sales.quantity = 403 AND sales.salesid BETWEEN 30 AND 40
Database: sales
Note: quantity greater than 90% of the average quantity = quantity > MULTIPLY(AVG(quantity), 0.9);
Question: List the customer's ID and last name of the customer that purchased a product with a quantity greater than 90% of the average quantity of all listed products.
SQL: SELECT customers.customerid, customers.lastname FROM sales INNER JOIN customers ON sales.customerid = customers.customerid WHERE sales.quantity > ( SELECT avg(quantity) FROM sales ) * 0.9
Database: sales
Note: sales ID ranges from 1 to 200 refers to salesid between 1 and 200; percentage = MULTIPLY(DIVIDE(SUM(price between 200 and 300), COUNT(price)), 1.0);
Question: Among the sales ID ranges from 1 to 200, what is the percentage of the products with a price ranging from 200 to 300?
SQL: SELECT cast(sum(iif(products.price BETWEEN 200 AND 300, 1, 0)) AS REAL) * 100 / count(products.price) FROM sales INNER JOIN products ON sales.productid = products.productid WHERE sales.salesid BETWEEN 1 AND 200
Database: sales
Note: most expensive product refers to MAX(price);
Question: What is the name of the most expensive product?
SQL: SELECT name FROM products WHERE price = ( SELECT max(price) FROM products )
Database: sales
Question: How many customers are named Madison?
SQL: SELECT count(customerid) FROM customers WHERE firstname = 'Madison'
Database: sales
Note: types of HL Touring Frames refers to name like '%HL Touring Frame%';
Question: How many types of "HL Touring Frames" are there?
SQL: SELECT count(productid) FROM products WHERE name LIKE '%HL Touring Frame%'
Database: sales
Note: most common last name refers to MAX(COUNT(lastname));
Question: How many customers share the most common last name?
SQL: SELECT count(customerid) FROM customers GROUP BY lastname ORDER BY count(lastname) DESC LIMIT 1
Database: sales
Note: free gift refers to price = 0;
Question: How many free or gift products are there?
SQL: SELECT count(productid) FROM products WHERE price = 0
Database: sales
Note: name of the sales person = firstname, middleinitial, lastname; highest number of sales refers to MAX(COUNT(salesid));
Question: What is the name of the sales person who handled the highest number of sales?
SQL: SELECT employees.firstname, employees.middleinitial, employees.lastname FROM employees INNER JOIN sales ON sales.salespersonid = employees.employeeid GROUP BY sales.salespersonid, employees.firstname, employees.middleinitial, employees.lastname ORDER BY count(sales.salesid) DESC LIMIT 1
Database: sales
Note: full name of the customer = firstname, middleinitial, lastname; highest amount of total price refers to MAX(MULTIPLY(quantity, price));
Question: What is the full name of the customer who purchased the highest amount of total price in a single purchase?
SQL: SELECT customers.firstname, customers.middleinitial, customers.lastname FROM sales INNER JOIN customers ON sales.customerid = customers.customerid INNER JOIN products ON sales.productid = products.productid GROUP BY sales.salesid, sales.quantity, products.price, firstname, middleinitial, lastname ORDER BY sales.quantity * products.price DESC LIMIT 1
Database: sales
Note: Mountain-500 Black 42' is name of product; sold in total = SUM(quantity);
Question: How many "Mountain-500 Black 42" were sold in total?
SQL: SELECT sum(sales.quantity) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name = 'Mountain-500 Black, 42'
Database: sales
Note: total amount of sales = SUM(MULTIPLY(quantity, price));
Question: How much is the total amount of sales handled by Heather McBadden?
SQL: SELECT sum(sales.quantity * products.price) FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid INNER JOIN products ON sales.productid = products.productid WHERE employees.firstname = 'Heather' AND employees.lastname = 'McBadden'
Database: sales
Note: Mountain-100 Silver, 38' is name of product;
Question: How many "Mountain-100 Silver, 38" were sold by Stearns MacFeather?
SQL: SELECT sum(sales.quantity) FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid INNER JOIN products ON sales.productid = products.productid WHERE employees.firstname = 'Stearns' AND employees.lastname = 'MacFeather' AND products.name = 'Mountain-100 Silver, 38'
Database: sales
Question: How many type of products did Dalton M. Coleman purchase?
SQL: SELECT count(sales.productid) FROM customers INNER JOIN sales ON customers.customerid = sales.customerid WHERE customers.firstname = 'Dalton' AND customers.middleinitial = 'M' AND customers.lastname = 'Coleman'
Database: sales
Note: full names of employees = firstname, MiddleInitital, lastname; highest number of sales refers to MAX(COUNT(salesid));
Question: What are the full names of the top 3 employees who handled the highest number of sales?
SQL: SELECT employees.firstname, employees.middleinitial, employees.lastname FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid GROUP BY sales.salespersonid, employees.firstname, employees.middleinitial, employees.lastname ORDER BY count(sales.salesid) DESC LIMIT 3
Database: sales
Note: Mountain-500 Black product types refers to name like 'Mountain-500 Black%'; purchased the most refers to MAX(SUM(quantity));
Question: Among the "Mountain-500 Black" product types, which type was purchased the most?
SQL: SELECT products.name FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name LIKE 'Mountain-500 Black%' GROUP BY sales.quantity, products.name ORDER BY sum(sales.quantity) DESC LIMIT 1
Database: sales
Note: ML Road Frame-W - Yellow, 40' is name of product;
Question: How many employees sold "ML Road Frame-W - Yellow, 40"?
SQL: SELECT count(sales.salespersonid) FROM products INNER JOIN sales ON products.productid = sales.productid WHERE products.name = 'ML Road Frame-W - Yellow, 40'
Database: sales
Note: Chainring Bolts' is name of product;
Question: How many chainring bolts were sold under sales ID 551971?
SQL: SELECT sales.quantity FROM sales INNER JOIN products ON sales.productid = products.productid WHERE products.name = 'Chainring Bolts' AND sales.salesid = 551971
Database: sales
Note: over 20,000 quantities refers to quantity > 20000; 'Touring-2000 Blue, 50' is name of product;
Question: How many employees sold over 20,000 quantities of "Touring-2000 Blue, 50"?
SQL: SELECT count(*) FROM ( SELECT sum(quantity) FROM sales WHERE productid IN ( SELECT productid FROM products WHERE name = 'Touring-2000 Blue, 50' ) GROUP BY quantity, salespersonid HAVING sum(quantity) > 20000 )
Database: sales
Note: total cost = SUM(MULTIPLY(quantity, price)); 'Road-650, Red, 60' is name of product;
Question: What is the total cost of all the "Road-650, Red, 60" products that Abraham E. Bennet sold?
SQL: SELECT sum(sales.quantity * products.price) FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid INNER JOIN products ON sales.productid = products.productid WHERE employees.firstname = 'Abraham' AND employees.middleinitial = 'e' AND employees.lastname = 'Bennet' AND products.name = 'Road-650 Red, 60'
Database: sales
Note: highest total amount of quantity refers to MAX(quantity); overall total price = SUM(MULTIPLY(quantity, price));
Question: Which product has the highest total amount of quantity sold? Calculate its overall total price.
SQL: SELECT products.name, sum(sales.quantity * products.price) FROM products INNER JOIN sales ON products.productid = sales.productid GROUP BY products.productid, products.name ORDER BY sum(sales.quantity) DESC LIMIT 1
Database: sales
Question: List the first name of all the customers whose last name is Chen.
SQL: SELECT firstname, lastname FROM customers WHERE lastname = 'Chen'
Database: sales
Note: most common middle initial refers to MAX(COUNT(middleinitial));
Question: Among the employee names, what is the most common middle initial?
SQL: SELECT middleinitial FROM employees GROUP BY middleinitial ORDER BY count(middleinitial) DESC LIMIT 1
Database: sales
Note: average price = DIVIDE(SUM(price, COUNT(price))); cost refers to price; price BETWEEN 100 AND 200;
Question: What is the average price of products that cost between 100 and 200?
SQL: SELECT avg(price) FROM products WHERE price BETWEEN 100 AND 200
Database: sales
Note: full name of the customer = firstname, middleinitial, lastname; above-average quantity = quantity > AVG(quantity);
Question: Find and list the full name of customers who bought products above-average quantity.
SQL: SELECT customers.firstname, customers.middleinitial, customers.lastname FROM sales INNER JOIN customers ON sales.customerid = customers.customerid GROUP BY sales.quantity HAVING sales.quantity > ( SELECT avg(quantity) FROM sales )
Database: sales
Note: full name of the customer = firstname, middleinitial, lastname; most amount of products refers to MAX(MULTIPLY(quantity, price));
Question: Give the full name of the customer who bought the most amount of products.
SQL: SELECT customers.firstname, customers.middleinitial, customers.lastname FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN customers ON sales.customerid = customers.customerid ORDER BY sales.quantity * products.price DESC LIMIT 1
Database: sales
Note: Blade' is name of product; most amount of sales refers to MAX(MULTIPLY(quantity, price));
Question: Of the employees who sold Blade, who has the most amount of sales?
SQL: SELECT employees.firstname, employees.middleinitial, employees.lastname FROM employees INNER JOIN sales ON employees.employeeid = sales.salespersonid INNER JOIN products ON sales.productid = products.productid ORDER BY sales.quantity * products.price DESC LIMIT 1
Database: sales
Note: full name of the customer = firstname, middleinitial, lastname; more than 50,000 in the amount refers to MULTIPLY(quantity, price) > 50000;
Question: List the full name of customers who spend more than 50,000 in descending order the amount spend.
SQL: SELECT DISTINCT customers.firstname, customers.middleinitial, customers.lastname FROM products INNER JOIN sales ON products.productid = sales.productid INNER JOIN customers ON sales.customerid = customers.customerid WHERE sales.quantity * products.price > 50000
Database: sales
Note: most quantity refers to MAX(quantity);
Question: Name the product that sold the most quantity.
SQL: SELECT products.name FROM sales INNER JOIN products ON sales.productid = products.productid ORDER BY sales.quantity DESC LIMIT 1
Database: sales
Note: below the average quantity refers to quantity < AVG(quantity);
Question: Find and list the products that sold below the average quantity.
SQL: SELECT DISTINCT products.name FROM sales INNER JOIN products ON sales.productid = products.productid WHERE sales.quantity < ( SELECT avg(quantity) FROM sales )