Chinastark/bird_dataset huggingface dataset:
Database: retail_world
Note: no longer continuous refers to Discontinued = 1; USA refers to country = 'USA';
Question: Among the products that are no longer in continuous production, how many of them have their supplier in the USA?
SQL: SELECT count(products.discontinued) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.country = 'USA' AND products.discontinued = 1
Database: retail_world
Note: supplier of the product refers to CompanyName; highest unit price refers to MAX(unitprice);
Question: Who is the supplier of 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: average salary = DIVIDE(SUM(Salary), COUNT(employeeid)); employees who takes charge of over 4 territories refers to employeeid WHERE COUNT(TerritoryID) > 4;
Question: What is the average salary of the employees who takes charge of the sales of over 4 territories?
SQL: SELECT avg(employees.salary) FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid GROUP BY employees.employeeid HAVING count(employeeterritories.territoryid) > 4
Database: retail_world
Note: how much lower in percentage = MULTIPLY(DIVIDE(SUBTRACT(products.unitprice, Order Details.unitprice), products.unitprice), 100); Ikura refers to productname = 'Ikura'; order no. refers to orderid;
Question: How much lower in percentage is the unit price of Ikura in order no. 10273 than its standard unit price?
SQL: SELECT cast((products.unitprice - order details.unitprice) AS REAL) * 100 / products.unitprice FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.orderid = 10273 AND products.productname = 'Ikura'
Database: retail_world
Note: average = AVG(quantity); Ikura refers to productname = 'Ikura';
Question: What is the average quantity of Ikura ordered in one order?
SQL: SELECT cast(sum(order details.quantity) AS REAL) / count(order details.orderid) FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE products.productname = 'Ikura'
Database: retail_world
Note: order no. refers to orderid; biggest ratio = MAX(DIVIDE(unitsOnOrder, unitsInStock));
Question: Among the products ordered in order no. 10248, which product has the biggest ratio of units on order to units in stock?
SQL: SELECT products.productname FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.orderid = 10248 ORDER BY products.unitsonorder / products.unitsinstock DESC LIMIT 1
Database: retail_world
Note: full name = firstname, lastname; youngest refers to latest birthdate;
Question: Give the full name of the youngest employee.
SQL: SELECT firstname, lastname FROM employees WHERE birthdate = ( SELECT max(birthdate) FROM employees )
Database: retail_world
Note: newest hired refers to latest HireDate; full name = firstname, lastname;
Question: Who is the newest hired employee? Give the full name.
SQL: SELECT firstname, lastname FROM employees WHERE hiredate = ( SELECT max(hiredate) FROM employees )
Database: retail_world
Question: Provide the number of orders that were handled by Michael Suyama.
SQL: SELECT count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.firstname = 'Michael' AND employees.lastname = 'Suyama'
Database: retail_world
Note: name of territory refers to Territorydescription; Mr. refers to TitleOfCourtesy = 'Mr';
Question: Give the name of the territory where Mr. Robert King works.
SQL: SELECT territories.territorydescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE employees.titleofcourtesy = 'Mr.' AND employees.firstname = 'Robert' AND employees.lastname = 'King'
Database: retail_world
Note: Ms. refers to TitleOfCourtesy = 'Ms'; ReportsTo’ represents a hierarchical relationship where the person being reported to is usually the direct supervisor of the reporter; name of the territory refers to Territorydescription;
Question: Which territory does Ms. Laura Callahan's direct supervisor work in? Give the name of the territory.
SQL: SELECT territories.territorydescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE employees.employeeid = ( SELECT reportsto FROM employees WHERE titleofcourtesy = 'Ms.' AND firstname = 'Laura' AND lastname = 'Callahan' )
Database: retail_world
Note: Santa Monica refers to Territorydescription = 'Santa Monica'; full name = firstname, MiddleName, lastname;
Question: Who is in charge of the "Santa Monica" territory? Give the full name.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE territories.territorydescription = 'Santa Monica'
Database: retail_world
Note: home phone number refers to Homephone; Savannah refers to Territorydescription = 'Savannah';
Question: Give the home phone number of the employee who is in charge of "Savannah" territory.
SQL: SELECT employees.homephone FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE territories.territorydescription = 'Savannah'
Database: retail_world
Note: HILLA refers to customerid = 'HILAA'; on 1997/12/25 refers to orderdate = '1997/12/25';
Question: For the order from "HILAA" on 1997/12/25, what was the total quantity of the products in that order?
SQL: SELECT sum(order details.quantity) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE orders.customerid = 'HILAA' AND orders.orderdate LIKE '1997-12-25%'
Database: retail_world
Note: highest freight refers to MAX(Freight); kinds of products refers to productid;
Question: For the order paying the highest freight, how many kinds of products does it contain?
SQL: SELECT count(order details.productid) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid WHERE orders.freight = ( SELECT max(freight) FROM orders ) GROUP BY orders.orderid
Database: retail_world
Note: name of the shipper company refers to ShipName; order No. refers to orderid;
Question: Tell the name of the shipper company for the order No.10585.
SQL: SELECT shippers.companyname FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.orderid = 10585
Database: retail_world
Note: Federal Shipping refers to CompanyName = 'Federal Shipping';
Question: Give the number of orders that were shipped by "Federal Shipping".
SQL: SELECT count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Federal Shipping'
Database: retail_world
Note: kinds of products refers to productid; category refers to categoryname;
Question: How many kinds of products are there in the the category of "dairy products"?
SQL: SELECT count(products.productid) FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE categories.categoryname = 'Dairy Products'
Database: retail_world
Note: category refers to categoryname; tofu refers to productname = 'Tofu';
Question: Which category does "tofu" belong to?
SQL: SELECT categories.categoryname FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE products.productname = 'Tofu'
Database: retail_world
Note: total production of the products = add(units in stock , units on order); supplier “Escargots Nouveaux” refers to CompanyName = 'Escargots Nouveaux';
Question: What is the total production of the products from the supplier “Escargots Nouveaux”?
SQL: SELECT sum(products.unitsinstock + products.unitsonorder) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Escargots Nouveaux'
Database: retail_world
Note: supplier "Nord-Ost-Fisch Handelsgesellschaft mbH" refers to CompanyName = 'Nord-Ost-Fisch Handelsgesellschaft mbH';
Question: Give the reorder level for the products from the supplier "Nord-Ost-Fisch Handelsgesellschaft mbH".
SQL: SELECT products.reorderlevel FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Nord-Ost-Fisch Handelsgesellschaft mbH'
Database: retail_world
Note: supplied by refers to CompanyName;
Question: How many kinds of products are supplied by "Karkki Oy" company?
SQL: SELECT count(products.productid) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Karkki Oy'
Database: retail_world
Note: product refers to productname;
Question: Give the contact name of the supplier for the product "Gudbrandsdalsost".
SQL: SELECT suppliers.contactname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Gudbrandsdalsost'
Database: retail_world
Note: "Scottish Longbreads" refers to productname = 'Scottish Longbreads';
Question: Tell the country name of the supplier for "Scottish Longbreads".
SQL: SELECT suppliers.country FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Scottish Longbreads'
Database: retail_world
Note: "Northern" region refers to Regiondescription = 'Northern';
Question: Give the number of territories in the "Northern" region.
SQL: SELECT count(territories.territoryid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Northern'
Database: retail_world
Note: region refers to RegionID; "Columbia" refers to Territorydescription = 'Columbia';
Question: Which region is "Columbia" in?
SQL: SELECT region.regiondescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE territories.territorydescription = 'Columbia'
Database: retail_world
Note: Customer "WHITC" refers to customerid = 'WHITC'; shipper company "united Package" refers to CompanyName = 'united Package'; percentage = divide(count(shipperid where CompanyName = 'united Package') , count(shipperid)) * 100%;
Question: For the orders of Customer "WHITC", what is the percentage of the orders were fulfilled with shipper company "United Package"?
SQL: SELECT cast(count(CASE WHEN shippers.companyname = 'United Package' THEN 1 ELSE NULL END) AS REAL) * 100 / count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.customerid = 'WHITC'
Database: retail_world
Note: percent = divide(subtract(count(orderid where CompanyName = 'united Package') , count(orderid where CompanyName = 'Speedy Express')) , count(orderid where CompanyName = 'Speedy Express')) * 100%;
Question: How many percent more orders were fulfilled with shipper company "United Package" than with "Speedy Express"?
SQL: SELECT cast((count(CASE WHEN shippers.companyname = 'United Package' THEN 1 ELSE NULL END) - count(CASE WHEN shippers.companyname = 'Speedy Express' THEN 1 ELSE NULL END)) AS REAL) * 100 / count(CASE WHEN shippers.companyname = 'Speedy Express' THEN 1 ELSE NULL END) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid
Database: retail_world
Note: "Eastern Region" refers to Regiondescription = 'Eastern'; "Southern Region" refers to Regiondescription = 'Southern'; times = divide(count(Territorydescription where Regiondescription = 'Eastern') , count(Territorydescription where Regiondescription = 'Southern'));
Question: How many times is the number of territories in "Eastern Region" than "Southern Region"?
SQL: SELECT cast(( SELECT count(territories.territoryid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Eastern' ) AS REAL) / ( SELECT count(territories.territoryid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Southern' ) AS calu
Database: retail_world
Note: highest number refers to max(count(customerid));
Question: How many customers are there in the country with the highest number of customers?
SQL: SELECT count(customerid) FROM customers GROUP BY country ORDER BY count(customerid) DESC LIMIT 1
Database: retail_world
Note: freight of over 800 refers to Freight > 800;
Question: What are the order ids of the orders with freight of over 800?
SQL: SELECT orderid FROM orders WHERE freight > 800
Database: retail_world
Note: Island Trading refers to CompanyName = 'Island Trading'; complete address = address, city, Region, country, postalcode;
Question: What is the Island Trading customer's complete address?
SQL: SELECT address, city, region, country, postalcode FROM customers WHERE companyname = 'Island Trading'
Database: retail_world
Note: product refers to productname; most expensive refers to max(unitprice);
Question: What is the most expensive product?
SQL: SELECT productname FROM products WHERE unitprice = ( SELECT max(unitprice) FROM products )
Database: retail_world
Note: united States of America refers to country = 'USA';
Question: How many suppliers are there in the United States of America?
SQL: SELECT count(supplierid) FROM suppliers WHERE country = 'USA'
Database: retail_world
Note: product refers to productname; highest user satisfaction refers to max(ReorderLevel);
Question: Which product have the highest user satisfaction?
SQL: SELECT productname FROM products WHERE reorderlevel = ( SELECT max(reorderlevel) FROM products )
Database: retail_world
Note: full name refers to firstname lastname; highest salary refers to max(Salary);
Question: What is the full name of the employee with the highest salary?
SQL: SELECT firstname, lastname FROM employees WHERE salary = ( SELECT max(salary) FROM employees )
Database: retail_world
Note: discontinued refers to Discontinued = 1; name of products refers to productname;
Question: What are the names of the products that were discountinued?
SQL: SELECT productname FROM products WHERE discontinued = 1
Database: retail_world
Note: average salary = avg(Salary); sales representative refers to Title = 'Sales Representative'; in the united Kingdom refers to country = 'UK';
Question: What is the average salary of sales representatives in the United Kingdom?
SQL: SELECT avg(salary) FROM employees WHERE title = 'Sales Representative' AND country = 'UK'
Database: retail_world
Note: most widely used refers to max(count(ShipVia)); shipping company refers to CompanyName; in the united States of America refers to Shipcountry = 'USA';
Question: What is the most widely used shipping company in the United States of America?
SQL: SELECT shippers.companyname FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.shipcountry = 'USA' GROUP BY shippers.companyname ORDER BY count(shippers.companyname) DESC LIMIT 1
Database: retail_world
Note: Pavlova, Ltd. refers to CompanyName = 'Pavlova, Ltd.';
Question: How many products were supplied by Pavlova, Ltd.?
SQL: SELECT count(products.productname) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Pavlova, Ltd.'
Database: retail_world
Note: GREAL refers to customerid = 'GREAL'; via united Package refers to CompanyName = 'united Package';
Question: How many orders were shipped to GREAL via United Package?
SQL: SELECT count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.customerid = 'GREAL' AND shippers.companyname = 'United Package'
Database: retail_world
Note: name of the supplier refers to supplierid; highest user satisfaction refers to max(ReorderLevel);
Question: What are the names of the suppliers whose products have the highest user satisfaction?
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: via united Package refers to CompanyName = 'united Package';
Question: In total, how many orders were shipped via United Package?
SQL: SELECT count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'United Package'
Database: retail_world
Note: in Australia refers to country = 'Australia'; discontinued refers to Discontinued = 1;
Question: How many suppliers in Australia whose products were discontinued?
SQL: SELECT count(products.discontinued) FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.discontinued = 1 AND suppliers.country = 'Australia'
Database: retail_world
Note: total purchase price including freight refers to add(multiply(unitprice , quantity) , Freight); most expensive refers to max(unitprice);
Question: How much is the total purchase price, including freight, of the top 2 most expensive products?
SQL: SELECT order details.unitprice * order details.quantity + orders.freight FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid ORDER BY order details.unitprice * order details.quantity + orders.freight DESC LIMIT 2
Database: retail_world
Note: name of the supplier refers to supplierid; the most product refers to max(count(productid));
Question: What is the name of the supplier that supplies the most products to the company?
SQL: SELECT products.supplierid FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid GROUP BY products.supplierid ORDER BY count(*) DESC LIMIT 1
Database: retail_world
Note: unit price of no more than 5 refers to unitprice < 5; name of products refers to productname;
Question: What are the names of the products that were ordered that have a unit price of no more than 5?
SQL: SELECT DISTINCT products.productname FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.unitprice < 5
Database: retail_world
Note: highest number of territories refers to max(TerritoryID);
Question: What is the title of the employee with the highest number of territories in charge?
SQL: SELECT employees.title FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid GROUP BY employees.title ORDER BY count(employeeterritories.territoryid) DESC LIMIT 1
Database: retail_world
Note: most ordered refers to max(count(productid)); product refers to productid;
Question: What is the most ordered products by customers?
SQL: SELECT products.productid FROM products INNER JOIN `order details` ON products.productid = order details.productid GROUP BY products.productid ORDER BY count(*) DESC LIMIT 1
Database: retail_world
Note: with a doctorate refers to TitleOfCourtesy = 'Dr.';
Question: Which territories is the employee with a doctorate in charge of? List all of the territory descriptions.
SQL: SELECT territories.territorydescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE employees.titleofcourtesy = 'Dr.'
Database: retail_world
Note: in the Eastern region refers to Regiondescription = 'Eastern';
Question: What are the territory descriptions of territories in the Eastern region?
SQL: SELECT DISTINCT territories.territorydescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Eastern' ORDER BY territories.territorydescription
Database: retail_world
Note: sales representative refers to Title = 'Sales Representative'; average number of territories = divide(count(TerritoryID) , count(employeeid)) where Title = 'Sales Representative';
Question: What is the average number of territories do each sales representative is in charge of?
SQL: SELECT cast(count(employeeterritories.territoryid) AS REAL) / count(DISTINCT employees.employeeid) FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid WHERE employees.title = 'Sales Representative'
Database: retail_world
Note: beverage refers to categoryname = 'Beverages'; highest customer satisfaction refers to max(ReorderLevel);
Question: Among the beverages, which product has the highest customer satisfaction?
SQL: SELECT products.productname FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE categories.categoryname = 'Beverages' ORDER BY products.reorderlevel DESC LIMIT 1
Database: retail_world
Note: full name refers to firstname lastname; highest amount of orders refers to max(count(orderid));
Question: What is the full name of the employee who handled the highest amount of orders?
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid GROUP BY employees.firstname, employees.lastname ORDER BY count(*) DESC LIMIT 1
Database: retail_world
Note: highest freight refers to max(Freight);
Question: How many products were ordered in the order with the highest freight?
SQL: SELECT count(order details.productid) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid GROUP BY order details.productid ORDER BY count(orders.freight) DESC LIMIT 1
Database: retail_world
Note: seafood product refers to categoryname = 'Seafood'; product refers to productid; highest total production refers to max(add(units in stock, units on order));
Question: Among the seafood products, which product have the highest total production of the production?
SQL: SELECT products.productname FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE categories.categoryname = 'Seafood' ORDER BY products.unitsinstock + products.unitsonorder DESC LIMIT 1
Database: retail_world
Note: highest number of territories refers to max(TerritoryID); difference in salary = subtract(employeeA.Salary, employeeB.Salary);
Question: What is the difference in salary of the top 2 employees with the highest number of territories in charge?
SQL: SELECT max(salary) - min(salary) FROM ( SELECT employees.salary FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid GROUP BY employees.employeeid, employees.salary ORDER BY count(employeeterritories.territoryid) DESC LIMIT 2 ) employees
Database: retail_world
Note: more than fifty units in stock refers to unitsInStock > 50; average price = avg(unitprice where unitsInStock > 50);
Question: What is the average price of products with more than fifty units in stock?
SQL: SELECT sum(unitprice) / count(unitprice) FROM products WHERE unitsinstock > 50
Database: retail_world
Note: most customers refers to max(count(Relationship));
Question: List the company names of customers from the city with the most customers.
SQL: SELECT companyname FROM `customer and suppliers by city` WHERE city = ( SELECT city FROM `customer and suppliers by city` GROUP BY city ORDER BY count(relationship) DESC LIMIT 1 )
Database: retail_world
Note: from Madrid refers to city = 'Madrid';
Question: Find and list the company name, company contact name, and contact title of customers from Madrid.
SQL: SELECT companyname, contactname, contacttitle FROM customers WHERE city = 'Madrid'
Database: retail_world
Note: full name refers to firstname lastname; contact number refers to Homephone; descending order of age refers to order by birthdate desc limit 1;
Question: Give the full name and contact number of employees in descending order of age.
SQL: SELECT firstname, lastname, homephone FROM employees ORDER BY birthdate DESC
Database: retail_world
Note: average price = divide(sum(unitprice) , count(productid)); the UK refers to country = 'UK';
Question: Calculate the average price of products shipped to the UK.
SQL: SELECT avg(unitprice) AS AVG FROM invoices WHERE country = 'UK'