Chinastark/bird_dataset huggingface dataset:
Database: retail_world
Note: August of 1996 refers to orderdate = '1996-8'; highest amount of orders refers to MAX(COUNT(orderid));
Question: In August of 1996, how many orders were placed by the customer with the highest amount of orders?
SQL: SELECT count(orderid) FROM orders WHERE orderdate LIKE '1996-08%' GROUP BY customerid ORDER BY count(orderid) DESC LIMIT 1
Database: retail_world
Note: first employee that was hired refers to MIN(HireDate);
Question: How much is the salary of the first employee that was hired?
SQL: SELECT salary FROM employees WHERE hiredate = ( SELECT min(hiredate) FROM employees )
Database: retail_world
Note: oldest employee at the time he or she was hired refers to MAX(SUBTRACT(HireDate, birthdate));
Question: How old was the oldest employee at the time he or she was hired?
SQL: SELECT max(timestampdiff(YEAR, birthdate, hiredate)) FROM employees
Database: retail_world
Note: discontinued products refers to Discontinued = 1; total sales amount refers to SUM(MULTIPLY(unitprice, quantity));
Question: What is the total sales amount of all discontinued products?
SQL: SELECT sum(order details.unitprice * order details.quantity) FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE products.discontinued = 1
Database: retail_world
Note: discontinued products refers to Discontinued = 1; highest number of discontinued products refers to MAX(Discontinued = 1);
Question: What is the category of the product that has the highest number of discontinued products?
SQL: SELECT categories.categoryname FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE products.discontinued = 1 GROUP BY categories.categoryname ORDER BY count(products.productid) DESC LIMIT 1
Database: retail_world
Note: "Condiments" is the categoryname; in 1997 refers to year(orderdate) = 1997;
Question: How many condiments were sold in 1997?
SQL: SELECT count(products.productid) FROM categories INNER JOIN products ON categories.categoryid = products.categoryid INNER JOIN `order details` ON products.productid = order details.productid INNER JOIN orders ON order details.orderid = orders.orderid WHERE categories.categoryname = 'Condiments' AND categories.categoryid = 2 AND orders.orderdate LIKE '1997%'
Database: retail_world
Note: highest number of products refers to MAX(COUNT(productid));
Question: Who is the customer who purchased the highest number of products in a single order?
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid GROUP BY customers.companyname ORDER BY count(order details.productid) DESC LIMIT 1
Database: retail_world
Note: monthly average number of products refers to DIVIDE(SUM(orderid), 12); shipped via Federal Shipping refers to CompanyName = 'Federal Shipping'; for the year 1996 refers to year(ShippedDate) = 1996;
Question: What is the monthly average number of products shipped via Federal Shipping for the year 1996?
SQL: SELECT cast(sum(orders.shipvia) AS REAL) / 12 FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Federal Shipping' AND orders.shippeddate LIKE '1996%'
Database: retail_world
Note: supplied by "G'day, Mate" refers to CompanyName = 'G''day, Mate';
Question: Which products are being supplied by "G'day, Mate"? List all of their names.
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname LIKE 'G%day, Mate'
Database: retail_world
Note: highest number of territories refers to max(TerritoryID);
Question: How many territories are there in the region with the highest number of territories?
SQL: SELECT count(region.regiondescription), territories.territorydescription, count(*) AS num FROM territories INNER JOIN region ON territories.regionid = region.regionid GROUP BY territories.territorydescription ORDER BY num DESC LIMIT 1
Database: retail_world
Note: the highest unit price refers to MAX(unitprice);
Question: What is the company name of the supplier who supplies the product with the highest unit price?
SQL: SELECT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.unitprice = ( SELECT max(unitprice) FROM products )
Database: retail_world
Note: female employees refers to TitleOfCourtesy = 'Mrs.' or TitleOfCourtesy = 'Ms.'; in charge of 3 or more territories refers to TerritoryID >= 3;
Question: How many female employees are in charge of 3 or more territories?
SQL: SELECT count(eid) FROM ( SELECT employees.employeeid AS eid FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid WHERE employees.titleofcourtesy IN ('Ms.' OR 'Mrs.') GROUP BY employees.employeeid HAVING count(employeeterritories.territoryid) >= 3 ) employees
Database: retail_world
Note: highest user satisfaction refers to max(ReorderLevel);
Question: Who are the top 8 suppliers supplying the products with the highest user satisfaction?
SQL: SELECT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid ORDER BY products.reorderlevel DESC LIMIT 8
Database: retail_world
Note: biggest amount of purchase in a single order refers to MAX(MULTIPLY(unitprice, quantity)); before discount refers to Discount = 0;
Question: What is the company name of the customer who made the biggest amount of purchase in a single order before discount?
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE order details.discount = 0 GROUP BY customers.companyname ORDER BY sum(order details.unitprice * order details.quantity) DESC LIMIT 1
Database: retail_world
Note: in December 1996 refers to year(orderdate) = 1996 AND month(orderdate) = 12; excluding discounts refers to Discount = 0; total amount of sales refers to MULTIPLY((unitprice, quantity));
Question: What was the total amount of sales handled by Nancy Davolio in December 1996, excluding discounts?
SQL: SELECT sum(order details.unitprice * order details.quantity) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE employees.firstname = 'Nancy' AND employees.lastname = 'Davolio' AND orders.orderdate LIKE '1996-12%' AND order details.discount = 0
Database: retail_world
Note: year 1997 refers to year(orderdate) = 1997; total amount of sales refers to (unitprice * quantity);
Question: What is the total amount of sales made in the year 1997?
SQL: SELECT sum(order details.unitprice * order details.quantity * (1 - order details.discount)) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE orders.orderdate LIKE '1997%'
Database: retail_world
Note: from 1997 to 1998 refers to ShippedDate > '1996-1-1' and ShippedDate < '1998-12-31'; average annual amount refers to SUM(MULTIPLY(unitprice, quantity, SUBTRACT(1, Discount)));
Question: What is the average annual amount of shipped sales from 1997 to 1998?
SQL: SELECT sum(order details.unitprice * order details.quantity * (1 - order details.discount)) / 3 FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE orders.shippeddate BETWEEN '1996-01-01 00:00:00' AND '1998-12-31 23:59:59'
Database: retail_world
Note: shipped to Venezuela refers to Shipcountry = 'Venezuela'; in 1996 refers to year(ShippedDate) = '1996';
Question: How many orders were shipped to Venezuela in 1996?
SQL: SELECT count(orderid) FROM orders WHERE shipcountry = 'Venezuela' AND strftime('%Y', shippeddate) = '1996'
Database: retail_world
Note: condiments category refers to categoryname = 'Condiments'; the ID refers to categoryid;
Question: What are the ID and description of the condiments category?
SQL: SELECT categoryid, description FROM categories WHERE categoryname = 'Condiments'
Database: retail_world
Note: total payment is greater than 15000 refers to MULTIPLY((quantity * unitprice * (1 - Discount))) > 15000;
Question: List the order IDs, product IDs and unit price of orders which total payment is greater than 15000.
SQL: SELECT productid, orderid, unitprice FROM `order details` WHERE unitprice * quantity * (1 - discount) > 15000
Database: retail_world
Question: Provide the territory IDs under employee ID of 7.
SQL: SELECT territoryid FROM employeeterritories WHERE employeeid = 7
Database: retail_world
Note: in Sydney refers to city = 'Sydney';
Question: Provide the supplier company name in Sydney and its homepage address if available.
SQL: SELECT companyname, homepage FROM suppliers WHERE city = 'Sydney'
Database: retail_world
Note: Vice President of Sales refers to Title = 'Vice President, Sales';
Question: Write down the full name of Vie President of Sales and his age when he was hired.
SQL: SELECT firstname, lastname , timestampdiff(YEAR, birthdate, hiredate) AS age FROM employees WHERE title = 'Vice President, Sales'
Database: retail_world
Note: located in Germany refers to country = 'Germany';
Question: List the supplier company names located in Germany.
SQL: SELECT companyname FROM suppliers WHERE country = 'Germany'
Database: retail_world
Note: in London refers to city = 'London'; ages in 2022 refers to SUBTRACT(2022, year(birthdate)); full names refers to firstname, lastname;
Question: List the employees' full names and ages in 2022 who lived in London.
SQL: SELECT titleofcourtesy, firstname, lastname , timestampdiff(YEAR, birthdate, now()) AS ages FROM employees WHERE city = 'London'
Database: retail_world
Note: in London refers to city = 'London';
Question: List down the customer company names, addresses, phones and faxes which are located in London.
SQL: SELECT companyname, address, phone, fax FROM customers WHERE city = 'London'
Database: retail_world
Note: Sales Manager refers to Title = 'Sales Manager'; full name refers to firstname, lastname;
Question: List the full name of employees and titles who have to report to Sales Manager.
SQL: SELECT firstname, lastname, title FROM employees WHERE reportsto = ( SELECT employeeid FROM employees WHERE title = 'Sales Manager' )
Database: retail_world
Note: located in Canada refers to country = 'Canada';
Question: List all the customer company names and cities located in Canada.
SQL: SELECT companyname, city FROM customers WHERE country = 'Canada'
Database: retail_world
Note: total production amount refers to ADD(unitsInstock, unitsOnOrder);
Question: Find the total production amount and product names which had "10 - 500 g pkgs." as quantity per unit.
SQL: SELECT unitsinstock + unitsonorder, productname FROM products WHERE quantityperunit = '10 - 500 g pkgs.'
Database: retail_world
Note: Highest reorder level refers to Max(ReorderLevel);
Question: List all the product names and categories of the highest reorder level.
SQL: SELECT products.productname, categories.categoryname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid ORDER BY products.reorderlevel DESC LIMIT 1
Database: retail_world
Note: total production amount is more than 120 refers to ADD(unitsInstock, unitsOnOrder) > 120;
Question: Describe the supplier companies, cities and products which total production amount is more than 120.
SQL: SELECT suppliers.companyname, suppliers.city, products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.unitsinstock + unitsonorder > 120
Database: retail_world
Note: "Escargots Nouveaux" company refers to CompanyName = 'Escargots Nouveaux';
Question: Provide the contact person name, title and supplied products by "Escargots Nouveaux" company.
SQL: SELECT suppliers.contactname, suppliers.contacttitle, products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Escargots Nouveaux'
Database: retail_world
Question: List the territory IDs, description and region description under the in-charge of Mrs. Margaret Peacock.
SQL: SELECT territories.territoryid, territories.territorydescription, region.regiondescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid INNER JOIN region ON territories.regionid = region.regionid WHERE employees.titleofcourtesy = 'Mrs.' AND employees.lastname = 'Peacock' AND employees.firstname = 'Margaret'
Database: retail_world
Note: company in Spain refers to country = 'Spain'; product supplied refers to productname;
Question: What were the products supplied by the company in Spain?
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.country = 'Spain'
Database: retail_world
Note: required on 3/26/1998 refers to RequiredDate = '1998-03-26 00:00:00'; products ordered refers to productname;
Question: What products were ordered by the customer ID "WILMK" which were required on 3/26/1998?
SQL: SELECT products.productname FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid WHERE orders.requireddate LIKE '1998-03-26%' AND orders.customerid = 'WILMK'
Database: retail_world
Note: meat/poultry category refers to categoryname = 'Meat/Poultry';
Question: Provide the list of product IDs and names under the meat/poultry category.
SQL: SELECT products.productname, categories.categoryname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE products.reorderlevel = ( SELECT max(reorderlevel) FROM products )
Database: retail_world
Note: in Ireland refers to country = 'Ireland';
Question: How many orders were made by the customers in Ireland.
SQL: SELECT count(orders.orderid) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE customers.country = 'Ireland'
Database: retail_world
Note: ordered in 1996 refers to year(orderdate) = 1996; in Norway refers to country = 'Norway';
Question: Provide the products list which were ordered in 1996 by the company in Norway.
SQL: SELECT products.productname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid WHERE customers.country = 'Norway' AND strftime('%Y', orders.orderdate) = '1996'
Database: retail_world
Note: shipping to Brazil refers to Shipcountry = 'Brazil'; in December, 1996  refers to year(orderdate) = 1996 and month(orderdate) = 12;
Question: Among orders shipping to Brazil, mention the supplier company of the order which was done by employee Anne Dodsworth in December, 1996 .
SQL: SELECT suppliers.companyname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE employees.firstname = 'Anne' AND employees.lastname = 'Dodsworth' AND orders.shipcountry = 'Brazil' AND orders.orderdate LIKE '1996-12%'
Database: retail_world
Note: full name refers to firstname, lastname; shipped to USA refers to Shipcountry = 'USA';
Question: Mention the oldest empoyee's full name, title, salary and number of orders which were shipped to USA by him.
SQL: SELECT employees.firstname, employees.lastname, employees.title, employees.salary , count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE shipcountry = 'USA' GROUP BY employees.firstname, employees.lastname, employees.title, employees.salary, employees.birthdate ORDER BY employees.birthdate LIMIT 1
Database: retail_world
Note: in Southern region refers to Regiondescription = 'Southern';
Question: List down the territory IDs and descriptions existed in Southern region.
SQL: SELECT territories.territoryid, territories.territorydescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Southern'
Database: retail_world
Note: under confections category refers to categoryname = 'Confections';
Question: Calculate the average payment per product under confections category.
SQL: SELECT sum(order details.unitprice * order details.quantity * (1 - order details.discount)) / count(products.productid) FROM products INNER JOIN `order details` ON products.productid = order details.productid INNER JOIN categories ON products.categoryid = categories.categoryid WHERE categories.categoryname = 'Confections'
Database: retail_world
Note: from San Francisco refers to city = 'San Francisco'; total payment refers to sum(MULTIPLY(unitprice, quantity, SUBTRACT(1, Discount)));
Question: Find the total payment of the orders by customers from San Francisco.
SQL: SELECT sum(order details.unitprice * order details.quantity * (1 - order details.discount)) AS totalpayment FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE customers.city = 'San Francisco'
Database: retail_world
Note: from Japan refers to country = 'Japan'; total production refers to ADD(unitsInstock, unitsOnOrder);
Question: Calculate the total production for each product which were supplied from Japan
SQL: SELECT sum(products.unitsinstock + products.unitsonorder) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.country = 'Japan'
Database: retail_world
Note: from Australia refers to country = 'Australia'; discontinued products refers to Discontinued = 1;
Question: Among the supplied products from Australia, describe the discontinued products and the category.
SQL: SELECT products.productname, categories.categoryname FROM suppliers INNER JOIN products ON suppliers.supplierid = products.supplierid INNER JOIN categories ON products.categoryid = categories.categoryid WHERE suppliers.country = 'Australia' AND products.discontinued = 1
Database: retail_world
Note: Ipoh Coffee refers to productname = 'Ipoh Coffee'; maximum in total payment refers to MAX(MULTIPLY(unitprice, quantity, SUBTRACT(1, Discount)));
Question: Mention the supplier country of Ipoh Coffee and the order ID which had maximum in total payment.
SQL: SELECT suppliers.country, order details.orderid FROM `order details` INNER JOIN products ON order details.productid = products.productid INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Ipoh Coffee' ORDER BY order details.unitprice * order details.quantity * (1 - order details.discount) DESC LIMIT 1
Database: retail_world
Note: ordered by ID 10979 refers to orderid = '10979'; total payment refers to SUM(MULTIPLY(unitprice, quantity, SUBTRACT(1, Discount)));
Question: Provide the list of products ordered by ID 10979 and calculate its total payment.
SQL: SELECT products.productname , sum(order details.unitprice * order details.quantity * (1 - order details.discount)) FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.orderid = 10979 GROUP BY products.productname
Database: retail_world
Note: grains/cereals category refers to categoryname = 'Grains/Cereals'; supplier with one digit ID refers to supplierid between 1 and 10;
Question: Among the products under grains/cereals category, provide the contact person and title of the supplier with one digit ID.
SQL: SELECT DISTINCT suppliers.contactname, suppliers.contacttitle FROM suppliers INNER JOIN products ON suppliers.supplierid = products.supplierid INNER JOIN categories ON products.categoryid = categories.categoryid WHERE categories.categoryname = 'Grains/Cereals' AND suppliers.supplierid BETWEEN 1 AND 10 LIMIT 1
Database: retail_world
Note: Speedy Express's refers to CompanyName = 'Speedy Express'; orders on 30th January, 1998 refers to ShippedDate = '1998-01-30 00:00:00';
Question: Provide Speedy Express's phone number and number of shipped orders on 30th January, 1998.
SQL: SELECT shippers.phone, count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Speedy Express' AND orders.shippeddate LIKE '1998-01-30%' GROUP BY shippers.phone
Database: retail_world
Note: the most overdue from required date refers to MIN(SUBTRACT(ShippedDate, RequiredDate) < 0);
Question: Describe the ordered products which were the most overdue from required date.
SQL: SELECT DISTINCT products.productname FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid WHERE datediff(orders.shippeddate, orders.requireddate) < 0
Database: retail_world
Note: shipped to Mexico refers to Shipcountry = 'Mexico'; in 1996 refers to year(ShippedDate) = 1996; charge of inside sales coordinator refers to Title = 'Inside Sales Coordinator';
Question: Under the in-charge of inside sales coordinator, provide the product lists which were shipped to Mexico in 1996.
SQL: SELECT products.productname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid WHERE employees.title = 'Inside Sales Coordinator' AND orders.shippeddate LIKE '1996%' AND orders.shipcountry = 'Mexico'
Database: retail_world
Note: 'dairy product' refers to categoryname; most popular reorder quantity refers to MAX(ReorderLevel);
Question: Identify the name of the most popular dairy product in terms of reorder quantity.
SQL: SELECT products.productname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE categories.categoryname = 'Dairy Products' AND products.reorderlevel = ( SELECT max(reorderlevel) FROM products )
Database: retail_world
Note: 'Mascarpone Fabioli' is a productname; calculation = SUM(unitsInStock, unitsOnOrder);
Question: Calculate the production volume of the dairy product 'Mascarpone Fabioli'.
SQL: SELECT sum(unitsinstock + unitsonorder) FROM products WHERE productname = 'Mascarpone Fabioli'
Database: retail_world
Note: name of product refers to productname; category of product refers to categoryname; the most expensive products refers to MAX(unitprice); the least expensive products refers to MIN(unitprice);
Question: Identify the name and product category for the most expensive and the least expensive products.
SQL: SELECT products.productname, categories.categoryname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE products.unitprice IN (( SELECT min(unitprice) FROM products ), ( SELECT max(unitprice) FROM products ))
Database: retail_world
Note: value refers to SUM(unitprice * quantity * SUBTRACT(1, Discount)); the largest order in value refers to MAX(value);
Question: Identify the customer, which placed the largest order in terms of value.
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid GROUP BY orders.customerid ORDER BY sum(order details.unitprice * order details.quantity * (1 - order details.discount)) DESC LIMIT 1
Database: retail_world
Note: Northern sales region refers to Regiondescription = 'Northern';
Question: Identify the number of employees in Northern sales region.
SQL: SELECT count(employeeterritories.employeeid) FROM territories INNER JOIN employeeterritories ON territories.territoryid = employeeterritories.territoryid INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Northern'
Database: retail_world
Note: calculation = DIVIDE(SUM(unitprice * quantity * SUBTRACT(1, Discount)), COUNT(orderid));
Question: What is the average value of the sales order?
SQL: SELECT sum(unitprice * quantity * (1 - discount)) / count(orderid) FROM `order details`