Chinastark/bird_dataset huggingface dataset:
Database: retail_world
Note: territories in the Southern region refer to Territorydescription WHERE Regiondescription = 'Southern';
Question: Make a list of all the territories in the Southern region.
SQL: SELECT DISTINCT territories.territorydescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Southern'
Database: retail_world
Note: prices on cheese refer to unitprice WHERE description = 'Cheeses';
Question: What are the prices on cheese products?
SQL: SELECT products.unitprice FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE categories.description = 'Cheeses'
Database: retail_world
Note: "Laughing Bacchus Wine Cellars" is the name of the company; orders refer to orderid;
Question: How many orders did "Laughing Bacchus Wine Cellars" make?
SQL: SELECT count(orders.orderid) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE customers.companyname = 'Laughing Bacchus Wine Cellars'
Database: retail_world
Note: products shipped to Starenweg 5 refer to productname where Shipaddress = 'Starenweg 5';
Question: List all the products that were shipped to Starenweg 5.
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.shipaddress = 'Starenweg 5' GROUP BY products.productname
Database: retail_world
Note: Bigfoot Breweries is the name of the company; products refer to productname;
Question: What are the products by the company "Bigfoot Breweries"?
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Bigfoot Breweries'
Database: retail_world
Note: Robert King is a full name of an employee where lastname = 'King' AND firstname = 'Robert'; names of territories refer to Territorydescription;
Question: What are the names of Robert King's territories?
SQL: SELECT territories.territorydescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE employees.lastname = 'King' AND employees.firstname = 'Robert'
Database: retail_world
Note: shipped to Switzerland refers to Shipcountry = 'Switzerland'; contact person refers to customers;
Question: Provide the name of the contact person who made the orders that shipped to Switzerland.
SQL: SELECT customers.contactname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.shipcountry = 'Switzerland' GROUP BY customers.contactname
Database: retail_world
Note: DIVIDE(COUNT(orderid where Title = 'Sales Representative'), COUNT(orderid)) as percentage;
Question: What proportion of orders are taken by the Sales Representative?
SQL: SELECT cast(count(CASE WHEN employees.title = 'Sales Representative' THEN 1 ELSE NULL END) AS REAL) * 100 / count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid
Database: retail_world
Note: "USA" is the country; PhD title of courtesy refers to TitleOfCourtesy = 'Dr.';
Question: Among the USA employess, how many of them has PhD title of courtesy?
SQL: SELECT count(country) FROM employees WHERE titleofcourtesy = 'Dr.' AND country = 'USA'
Database: retail_world
Note: ID 1 to 9 refers to employeeid BETWEEN 1 AND 9; Average salary = AVG(Salary);
Question: What is the average salary for employees from ID 1 to 9?
SQL: SELECT avg(salary) FROM employees WHERE employeeid BETWEEN 1 AND 9
Database: retail_world
Note: "UK" is the country; total salary refers to Sum(Salary);
Question: Calculate the total salary for employees from UK.
SQL: SELECT sum(salary) FROM employees WHERE country = 'UK'
Database: retail_world
Note: "Laura Callahan" refers to firstname = 'Laura AND lastname = 'Callahan;
Question: Is (206) 555-1189 the home phone number for Laura Callahan?
SQL: SELECT CASE WHEN homephone = '(206) 555-1189' THEN 'YES' ELSE 'NO' END FROM employees WHERE firstname = 'Laura' AND lastname = 'Callahan'
Database: retail_world
Note: highest salary refers to Max(Salary);
Question: Write down the notes of employee with the highest salary.
SQL: SELECT notes FROM employees WHERE salary = ( SELECT max(salary) FROM employees )
Database: retail_world
Question: List down the customer ids who placed order with Michael Suyama.
SQL: SELECT orders.customerid FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.firstname = 'Michael' AND employees.lastname = 'Suyama'
Database: retail_world
Question: Where are the ship countries of orders placed by Janet Leverling?
SQL: SELECT DISTINCT orders.shipcountry FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.firstname = 'Janet' AND employees.lastname = 'Leverling'
Database: retail_world
Question: How many orders have Margaret Peacock placed?
SQL: SELECT count(orders.employeeid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.firstname = 'Margaret' AND employees.lastname = 'Peacock'
Database: retail_world
Note: average salary = AVG(Salary);
Question: Calculate the average salary per order for Andrew Fuller.
SQL: SELECT cast(sum(employees.salary) AS REAL) / count(orders.employeeid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.firstname = 'Andrew' AND employees.lastname = 'Fuller'
Database: retail_world
Note: "Exotic Liquids" is the CompanyName;
Question: What are the product names of Exotic Liquids?
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Exotic Liquids'
Database: retail_world
Note: "Tokyo Traders" is the CompanyName;
Question: List down the quantity per unit for products of Tokyo Traders.
SQL: SELECT products.quantityperunit FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Tokyo Traders'
Database: retail_world
Note: "New Orleans Cajun Delights" is the CompanyName; discontinued refers to Discontinued = 1;
Question: How many products have been discountinued by New Orleans Cajun Delights?
SQL: SELECT count(products.discontinued) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'New Orleans Cajun Delights'
Database: retail_world
Note: "Formaggi Fortini s.r.l." is the CompanyName; average unit price = AVG(unitprice);
Question: Please calculate the average unit price for products of Formaggi Fortini s.r.l.
SQL: SELECT sum(products.unitprice) / count(products.supplierid) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Formaggi Fortini s.r.l.'
Database: retail_world
Note: Japan Supplier refers to country = 'Japan'; total product refers to Count (productname);
Question: Calculate the total products that are supplied by Japan suppliers.
SQL: SELECT count(products.supplierid) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.country = 'Japan'
Database: retail_world
Note: "Teatime Chocolate Biscuits" is the productname;
Question: What is the contact name for product Teatime Chocolate Biscuits?
SQL: SELECT suppliers.contactname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Teatime Chocolate Biscuits'
Database: retail_world
Note: Highest reorder level refers to Max(ReorderLevel);
Question: List down the company names that have the highest reorder level.
SQL: SELECT DISTINCT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.reorderlevel = ( SELECT max(reorderlevel) FROM products )
Database: retail_world
Note: "10 boxes x 12 pieces" is the quantityPerunit;
Question: What is the contact title for the person who supplied a product that is 10 boxes x 12 pieces.
SQL: SELECT suppliers.contacttitle FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.quantityperunit = '10 boxes x 12 pieces'
Database: retail_world
Note: "Exotic Liquids" is the CompanyName; total unit on order = Sum(unitsOnOrder);
Question: What is the total units on order from Exotic Liquids?
SQL: SELECT sum(products.unitsonorder) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Exotic Liquids'
Database: retail_world
Note: "Gai pturage" is the CompanyName; Percentage = Divide (Count(supplierid where CompanyName = 'Gai pturage'), Count (supplierid)) * 100;
Question: Calculate the percentage of products supplied by Gai pturage over all products.
SQL: SELECT cast(count(CASE WHEN suppliers.companyname = 'Gai pturage' THEN 1 ELSE NULL END) AS REAL) * 100 / count(products.supplierid) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid
Database: retail_world
Note: by descending in number of quantity in stock refers to max(unitsInStock);
Question: List the product ID of the top five products, by descending order, the number of quantities in stock.
SQL: SELECT productid FROM products ORDER BY unitsinstock DESC LIMIT 5
Database: retail_world
Note: discontinued refers to Discontinued = 1;
Question: Among the products, how many of them were discontinued in production?
SQL: SELECT count(*) FROM products WHERE discontinued = 1
Database: retail_world
Note: "Sales Manage" is the Title;
Question: Give me the address, home phone and salary of the Sales Manager.
SQL: SELECT address, homephone, salary FROM employees WHERE title = 'Sales Manager'
Database: retail_world
Note: "Vice Present of Sales" refers to Title = 'Vice President, Sales'; full name refers to firstname, lastname; url of photo refers to photoPath;
Question: What is the full name of the Vice President of Sales. Give me the URL of his/her photo.
SQL: SELECT firstname, lastname FROM employees WHERE title = 'Vice President, Sales'
Database: retail_world
Note: most total sales refers to Max(SaleAmount); companies refers to CompanyName;
Question: Write down the top ten companies with the most total sales by amount.
SQL: SELECT companyname FROM `sales totals by amount` ORDER BY saleamount DESC LIMIT 10
Database: retail_world
Note: average sales = AVG(productsales);
Question: What is the average sales for each categories?
SQL: SELECT avg(productsales) FROM `sales by category` GROUP BY categoryname
Database: retail_world
Note: "Uncle Bob's Organic Dried Pears" is the productname; total order quantity refers to Sum(quantity);
Question: Compute the total order quantity for Uncle Bob's Organic Dried Pears so far.
SQL: SELECT sum(order details.quantity) FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE products.productname LIKE 'Uncle Bob%s Organic Dried Pears'
Database: retail_world
Note: "Seafood" is the categoryname; order quantity of more than 50 refers to quantity > 50;
Question: Among the seafoods, how many of them have an order quantity of more than 50?
SQL: SELECT 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 = 'Seafood' AND order details.quantity > 50
Database: retail_world
Note: "Pavlova, Ltd" is the CompanyName; products refers to productname;
Question: List the products whose supplier is Pavlova, Ltd. Please include the product ID and re-order level.
SQL: SELECT products.productname, products.productid, products.reorderlevel FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Pavlova, Ltd.'
Database: retail_world
Note: discontinued product refers to Discontinued = 1; supplier refers to CompanyName;
Question: Who are the suppliers of the discontinued products?
SQL: SELECT DISTINCT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.discontinued = 1
Database: retail_world
Note: less than 4 territories refers to employeeid where Count(TerritoryID) < 4;
Question: Among the employees, give me the full names of those who have less than 4 territories.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid WHERE employeeterritories.employeeid < 4
Database: retail_world
Note: "Eastern" is the Regiondescription;
Question: How many employees have territories in the Eastern region?
SQL: SELECT count(DISTINCT employees.firstname) 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 region.regiondescription = 'Eastern'
Database: retail_world
Note: from 1/3/97 to 8/10/97 refers to 1997-03-01 < ShippedDate < 1997-10-08; 'Federal Shipping' is the CompanyName;
Question: From 1/3/97 to 8/10/97, how many orders were shipped via Federal Shipping?
SQL: SELECT count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Federal Shipping' AND orders.shippeddate BETWEEN '1997-03-01 00:00:00' AND '1997-10-08 23:59:59'
Database: retail_world
Note: "Brazil" is the Shipcountry; from 3/31/97 to 12/10/97 refers to 1997-03-31 < ShippedDate < 1997-10-12;
Question: Tally the customer ID of orders that were shipped to Brazil by Margaret Peacock from 3/31/97 to 12/10/97.
SQL: SELECT DISTINCT orders.customerid FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.lastname = 'Peacock' AND employees.firstname = 'Margaret' AND orders.shipcountry = 'Brazil' AND orders.shippeddate BETWEEN '1997-03-31 00:00:00' AND '1997-12-10 23:59:59'
Database: retail_world
Note: order quantity of 1 refers to quantity = 1;
Question: What is the re-order level of products that have an order quantity of 1?
SQL: SELECT products.reorderlevel FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.quantity = 1
Database: retail_world
Note: "Condiments" is the categoryname; Stock value = MULTIPLY( unitprice, unitInStock);
Question: What is the stock value of every condiments?
SQL: SELECT products.unitprice * products.unitsinstock FROM products INNER JOIN categories ON products.categoryid = categories.categoryid
Database: retail_world
Question: How many territories are owned by Anne Dodsworth?
SQL: SELECT count(employeeterritories.territoryid) FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid WHERE employees.firstname = 'Anne' AND employees.lastname = 'Dodsworth'
Database: retail_world
Note: "American" refers to country = 'USA'; longest delay in shipment refers to Max(Subtract(RequiredDate, ShippedDate)); customer refers to customerid;
Question: Which of the American customers have experienced a delay in the shipment and how long was the longest?
SQL: SELECT customers.companyname, timestampdiff(DAY, orders.shippeddate, orders.requireddate) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE customers.country = 'USA' AND timestampdiff(DAY, orders.shippeddate, orders.requireddate) < 0
Database: retail_world
Note: most total payment = Max(Multiply(quantity, unitprice, Subtract(1, Discount)));
Question: What is the contact name and phone number of the customer who has made the most total payment on the order to date?
SQL: SELECT customers.contactname, customers.phone FROM customers INNER JOIN orders ON customers.customerid = orders.customerid INNER JOIN `order details` ON orders.orderid = order details.orderid GROUP BY orders.orderid, customers.contactname, customers.phone ORDER BY sum(order details.unitprice * order details.quantity * (1 - order details.discount)) DESC LIMIT 1
Database: retail_world
Note: highest payment refers to Max(Multiply(quantity, unitprice, Subtract(1, Discount))); full name refers to firstname, lastname; his/her supervisor refers to 'ReportsTo';
Question: Who is the sales representative of the customer who has made the highest payment? Include the full name of employee and his/her supervisor.
SQL: SELECT employees.lastname, employees.firstname, employees.reportsto , order details.quantity * order details.unitprice * (1 - order details.discount) AS payment FROM `order details` INNER JOIN orders ON order details.orderid = orders.orderid INNER JOIN customers ON orders.customerid = customers.customerid INNER JOIN employees ON orders.employeeid = employees.employeeid ORDER BY payment DESC LIMIT 1
Database: retail_world
Note: "Berlin" is the city; 'Germany' is the country;
Question: How many customers are there in Berlin, Germany?
SQL: SELECT count(city) FROM customers WHERE country = 'Germany' AND city = 'Berlin'
Database: retail_world
Note: "Exotic Liquids" is the CompanyName of supplier;
Question: How many products does the company Exotic Liquids supply?
SQL: SELECT count(products.productname) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Exotic Liquids'
Database: retail_world
Note: lowest unit price refers to Min(unitprice);
Question: Which company has the lowest unit price? Please give the company name and the product name.
SQL: SELECT suppliers.companyname, products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.unitprice = ( SELECT min(unitprice) FROM products )
Database: retail_world
Note: "Tokyo Traders" is the CompanyName; average unit price = AVG(unitprice);
Question: What is the average unit price of Tokyo Traders' products?
SQL: SELECT sum(products.unitprice) / count(suppliers.supplierid) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Tokyo Traders'
Database: retail_world
Note: "Eastern" is the Regiondescription;
Question: How many territories are there in the Eastern region?
SQL: SELECT count(territories.regionid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Eastern'
Database: retail_world
Note: region refers to Regiondescription; most territories refers to Max(Count(TerritoryID));
Question: Which region has the most territories?
SQL: SELECT region.regionid FROM territories INNER JOIN region ON territories.regionid = region.regionid GROUP BY region.regionid ORDER BY count(territories.territoryid) DESC LIMIT 1
Database: retail_world
Note: region refers to Regiondescription;
Question: Which region does territory id 2116 belong to?
SQL: SELECT region.regiondescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE territories.territoryid = 2116
Database: retail_world
Note: "Madrid" is the city; in 1996 refers to YEAR (orderdate) = 1996; percentage = Divide (Count (customerid where city = 'Madrid'), Count (customerid)) * 100;
Question: What percentage of orders were placed by customers in Madrid city in 1996?
SQL: SELECT cast(count(CASE WHEN customers.city = 'Madrid' THEN 1 ELSE NULL END) AS REAL) * 100 / count(customers.city) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE strftime('%Y', orders.orderdate) = 1996
Database: retail_world
Note: full name refers to lastname, firstname;
Question: Please list the full names and titles of all employees.
SQL: SELECT firstname, lastname, title FROM employees
Database: retail_world
Note: highest salary refers to Max(Salary);
Question: Who has the highest salary? Please give their first name.
SQL: SELECT firstname, lastname FROM employees WHERE salary = ( SELECT max(salary) FROM employees )
Database: retail_world
Note: "Sales Representative" is the Title; higher than 2000 refers to Salary > 2000;
Question: How many sales representatives whose salaries are higher than 2000?
SQL: SELECT count(title) FROM employees WHERE salary > 2000 AND title = 'Sales Representative'
Database: retail_world
Note: in 1996 refers to YEAR (orderdate) = 1996; 'UK' is the country;
Question: In 1996, how many orders were from customers in the UK?
SQL: SELECT count(customers.customerid) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE strftime('%Y', orders.orderdate) = '1996' AND customers.country = 'UK'
Database: retail_world
Note: in 1998 refers to YEAR (orderdate) = 1998; most orders = Max(Count(customerid)); company refers to CompanyName;
Question: Which company had the most orders in 1998?
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE strftime('%Y', orders.orderdate) = '1998' GROUP BY customers.companyname ORDER BY count(orders.orderid) DESC LIMIT 1
Database: retail_world
Note: in 1996 refer to YEAR(orderdate) = 1996; number of order = Count(orderid);
Question: Please calculate the number of orders from customers by country in 1996.
SQL: SELECT count(orders.customerid) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE strftime('%Y', orders.orderdate) = '1996' GROUP BY customers.country
Database: retail_world
Note: "Hanna Moos" is the CompanyName; in 1999 refer to YEAR (orderdate) = 1999;
Question: How many orders were from Hanna Moos company in 1999?
SQL: SELECT count(orders.orderid) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE strftime('%Y', orders.orderdate) = '1999' AND customers.companyname = 'Hanna Moos'
Database: retail_world
Note: Berglunds snabbkp is the CompanyName; fastest shipping = Min(Subtract(ShippedDate, orderdate));
Question: How many days was the fastest shipping of Berglunds snabbkp's order?
SQL: SELECT datediff(orders.shippeddate, orders.orderdate) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE customers.companyname = 'Berglunds snabbkp' ORDER BY datediff(orders.shippeddate, orders.orderdate) LIMIT 1
Database: retail_world
Note: "10257" is the orderid; company refers to CompanyName;
Question: Which company placed the order with the id 10257?
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.orderid = 10257
Database: retail_world
Note: Around the Horn is the CompanyName; year with the most order refers to Year (orderdate) where Max(Count(orderid));
Question: In which year did Around the Horn place the most orders?
SQL: SELECT strftime('%Y', orders.orderdate) FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE customers.companyname = 'Around the Horn' GROUP BY strftime('%Y', orders.orderdate) ORDER BY count(orders.orderid) DESC LIMIT 1
Database: retail_world
Note: "Andrew Fuller" refers to firstname = 'Andrew' AND lastname = 'Fuller'; report to refers to ReportsTo ! = NULL;
Question: How many employees report to Andrew Fuller?
SQL: SELECT count(employeeid) FROM employees WHERE reportsto = ( SELECT employeeid FROM employees WHERE lastname = 'Fuller' AND firstname = 'Andrew' )
Database: retail_world
Note: majority of the suppliers located refers to MAX(COUNT(supplierid));
Question: Which country are the majority of the suppliers located?
SQL: SELECT country FROM suppliers GROUP BY country ORDER BY count(supplierid) DESC LIMIT 1
Database: retail_world
Note: full name refers to lastname, firstname; the Sales Manager refers to Title = 'Sales Manager'; report to refers to ReportsTo is not NULL;
Question: What is the full name of the employees who report to the Sales Manager?
SQL: SELECT firstname, lastname FROM employees WHERE reportsto = ( SELECT employeeid FROM employees WHERE title = 'Sales Manager' )