Chinastark/bird_dataset huggingface dataset:
Database: retail_world
Note: the most amount refers to max(sum(quantity));
Question: Among all the orders, which products sold for the most amount?
SQL: SELECT productid FROM `order details` GROUP BY productid ORDER BY sum(quantity) DESC LIMIT 1
Database: retail_world
Note: more than thirty dollars per unit refers to unitprice > 30;
Question: List the name, address, and phone number of companies that supply products for more than thirty dollars per unit.
SQL: SELECT suppliers.companyname, suppliers.address, suppliers.phone FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.unitprice > 30
Database: retail_world
Note: paid more than average in freight refers to Freight > divide(sum(Freight) , count(orderid));
Question: Among the customers, list customers' company names and addresses who paid more than average in freight.
SQL: SELECT DISTINCT customers.companyname, customers.address FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.freight > ( SELECT avg(freight) FROM orders )
Database: retail_world
Note: full name refers to firstname lastname; Wilton refers to Territorydescription = 'Wilton';
Question: Find and list the full name of employees who are from the territory, Wilton.
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 = 'Wilton'
Database: retail_world
Note: non-US refers to country <> 'USA'; discontinued refers to Discontinued = 1;
Question: List the names of non-US suppliers that have discontinued.
SQL: SELECT DISTINCT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.discontinued = 1 AND suppliers.country != 'USA'
Database: retail_world
Note: most costly refers to max(add(unit price , Freight)); in 1998 refers to orderdate >= '1998-01-01 00:00:00' AND orderdate < '1999-01-01 00:00:00';
Question: List the top five most costly products in 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.orderdate LIKE '1998%' ORDER BY products.unitprice + orders.freight DESC LIMIT 5
Database: retail_world
Note: from Canada refers to country = 'Canada'; Federal Shipping refers to ShipName = 'Federal Shipping';
Question: Of the customers who are from Canada, how many used Federal Shipping?
SQL: SELECT count(customers.customerid) FROM shippers INNER JOIN orders ON shippers.shipperid = orders.shipvia INNER JOIN customers ON orders.customerid = customers.customerid WHERE orders.shipname = 'Federal Shipping'
Database: retail_world
Note: most ordered refers to max(COUNT(orderid));
Question: List the name of the top ten most ordered product's names in descending order of the number of orders.
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 GROUP BY products.productname ORDER BY count(*) DESC LIMIT 10
Database: retail_world
Note: supplier refers to supplierid; most amount refers to max(count(productid));
Question: Which supplier supplies the most amount of products?
SQL: SELECT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid GROUP BY suppliers.supplierid, suppliers.companyname ORDER BY count(products.productname) DESC LIMIT 1
Database: retail_world
Note: full name refers to firstname lastname; region refers to Regiondescription;
Question: Please list the full name and region of each employee in alphabetical order.
SQL: SELECT DISTINCT employees.firstname, employees.lastname, 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 ORDER BY employees.firstname
Database: retail_world
Note: most amount of orders refers to max(count(orderid)); in 1996 refers to orderdate >= '1996-01-01 00:00:00' AND orderdate < '1997-01-01 00:00:00'; full name refers to firstname, lastname;
Question: Which employee handled the most amount of orders in 1996? Give the full name, title, and address of this employee.
SQL: SELECT firstname, lastname, title, address FROM employees WHERE employeeid = ( SELECT employees.employeeid FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderdate BETWEEN '1996-01-01 00:00:00' AND '1997-01-01 00:00:00' GROUP BY employees.employeeid ORDER BY count(orders.orderid) DESC LIMIT 1 )
Database: retail_world
Note: via united Package refers to CompanyName = 'united Package'; in 1997 refers to orderdate >= '1997-01-01 00:00:00' AND orderdate < '1998-01-01 00:00:00'; average unit price = divide(sum(unitprice), count(shipperid));
Question: What was the average unit price of products shipped via United Package in 1997?
SQL: SELECT avg(order details.unitprice) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.orderdate LIKE '1997%' AND shippers.companyname = 'United Package'
Database: retail_world
Note: through Speedy Express refers to CompanyName = 'Speedy Express'; percentage = divide(count(shipperid where CompanyName = 'Speedy Express') , count(shipperid)) * 100%;
Question: Calculate the percentage of shipping done through Speedy Express.
SQL: SELECT cast(count(CASE WHEN shippers.companyname = 'Speedy Express' THEN 1 ELSE NULL END) AS REAL) * 100 / count(orders.shipvia) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid
Database: retail_world
Note: courtesy title refers to TitleOfCourtesy; the lowest salary refers to MIN(Salary);
Question: Indicate the courtesy title of the 3 employees who have the lowest salary.
SQL: SELECT titleofcourtesy FROM employees ORDER BY salary LIMIT 3
Database: retail_world
Note: report to represents a hierarchical relationship where the person being reported to is usually the direct supervisor of the reporter; Vice President of Sales refers to Title = 'Vice President, Sales';
Question: What is the last name of the employees who must report to the Vice President of Sales?
SQL: SELECT lastname FROM employees WHERE reportsto = ( SELECT employeeid FROM employees WHERE title = 'Vice President, Sales' )
Database: retail_world
Note: the highest total price paid for an order can be calculated as MAX(MULTIPLY(unitprice, quantity, SUBTRACT(1-Discount)));
Question: What is the highest total price paid for an order?
SQL: SELECT unitprice * quantity * (1 - discount) AS thetop FROM `order details` ORDER BY unitprice * quantity * (1 - discount) DESC LIMIT 1
Database: retail_world
Note: 3 products produced in greater quantity refer to MAX(SUM(unitsInStock, unitsOnOrder)) Limit 3;
Question: Which 3 products are produced in greater quantity?
SQL: SELECT productname FROM products ORDER BY unitsinstock + unitsonorder DESC LIMIT 3
Database: retail_world
Note: High reorder level generally means high user satisfaction of the product and vice versa; the least satisfaction refers to MIN(ReorderLevel); the highest unit price refers to MAX(unitprice);
Question: Of the 10 products with the highest unit price, identify by their ID the ones that have generated the least satisfaction.
SQL: SELECT productid FROM products ORDER BY reorderlevel ASC, unitprice DESC LIMIT 1
Database: retail_world
Note: non-discontinued products in the dairy category refer to productid where Discontinued = 0 and categoryname = 'Dairy products';
Question: How many non-discontinued products are there in the dairy category?
SQL: SELECT count(categories.categoryid) FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE categories.categoryname = 'Dairy Products' AND products.discontinued = 0
Database: retail_world
Note: territories refer to Territorydescription; Title = 'Inside Sales Coordinator';
Question: What territories is the Inside Sales Coordinator in charge of?
SQL: SELECT territories.territorydescription FROM employees INNER JOIN employeeterritories ON employees.employeeid = employeeterritories.employeeid INNER JOIN territories ON employeeterritories.territoryid = territories.territoryid WHERE employees.title = 'Inside Sales Coordinator'
Database: retail_world
Note: freighted products for a value greater than 2,000,000 refer to Freight > 2000000; name of companies refers to CompanyName;
Question: Indicate the name of the companies that have freighted products for a value greater than 2,000,000.
SQL: SELECT customers.companyname FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.freight > 2000000
Database: retail_world
Note: shipped the most times refer to MAX(COUNT(ShipVia)); city of Aachen refers to Shipcity = 'Aache'; companies refers to CompanyName;
Question: Through which companies have products been shipped the most times to the city of Aachen?
SQL: SELECT shippers.companyname FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.shipcity = 'Aachen' GROUP BY shippers.companyname ORDER BY count(orders.shipvia) DESC LIMIT 1
Database: retail_world
Note: full names = firstname, lastname; Northern region refers to Regiondescription = 'Northern';
Question: List the full name of all employees who work in the Northern region.
SQL: SELECT DISTINCT employees.firstname, employees.lastname 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 = 'Northern'
Database: retail_world
Note: contact person refers to contactname; Pavlova is the name of the product;
Question: What is the name of the contact person of the Pavlova supplier company?
SQL: SELECT suppliers.contactname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Pavlova'
Database: retail_world
Note: shipped to the city of Paris refers to Shipcity = 'Paris';
Question: Indicate the name of the products that have been shipped to the city of Paris.
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.shipcity = 'Paris'
Database: retail_world
Note: the least shipped product refers productname where MIN(quantity);
Question: What product is the least shipped to the postal code 28023?
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.postalcode = 28023 ORDER BY order details.quantity LIMIT 1
Database: retail_world
Note: full names = firstname, lastname; report to represents a hierarchical relationship where the person being reported to is usually the direct supervisor of the reporter; Andrew Fuller refers to employees WHERE firstname = 'Andrew' AND lastname = 'Fuller'; Southern region refers to Regiondescription = 'Southern';
Question: What is the full name of the employee in charge of the Southern region who is to report to Andrew Fuller?
SQL: SELECT DISTINCT employees.firstname, employees.lastname 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 = 'Southern' AND employees.reportsto = ( SELECT employeeid FROM employees WHERE firstname = 'Andrew' AND lastname = 'Fuller' )
Database: retail_world
Note: 9 units of Filo Mix refer to productname where quantity = 9; Du monde entier is the name of the customer; date refers to orderdate;
Question: On what date did the Du monde entier company request that 9 units of Filo Mix be sent to it?
SQL: SELECT orders.orderdate 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 products.productname = 'Filo Mix' AND order details.quantity = 9 AND customers.companyname = 'Du monde entier'
Database: retail_world
Note: order number 10933 refers to orderid = 10933;
Question: Indicate the name of the categories to which the products of order number 10933 belong.
SQL: SELECT categories.categoryname FROM products INNER JOIN `order details` ON products.productid = order details.productid INNER JOIN categories ON products.categoryid = categories.categoryid WHERE order details.orderid = 10933
Database: retail_world
Note: phone refers to Homephone; Portsmouth territory refers to Territorydescription = 'Portsmouth';
Question: What is the phone number for the employee in charge of the Portsmouth 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 = 'Portsmouth'
Database: retail_world
Note: Federal Shipping refers to CompanyName = 'Federal Shipping'; DIVIDE(SUM(quantity), COUNT(productid)) where CompanyName = 'Federal Shipping' and ShippedDate >= '1996-11-01 00:00:00' AND ShippedDate < '1996-12-01 00:00:00';
Question: What is the average quantity of product that have been shipped by Federal Shipping in November 1996?
SQL: SELECT cast(sum(order details.quantity) AS REAL) / count(order details.orderid) FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.shippeddate LIKE '1996-11%' AND shippers.companyname = 'Federal Shipping'
Database: retail_world
Note: DIVIDE(COUNT(orderid where CompanyName = 'united Package' and ShippedDate >= '1996-09-01 00:00:00' AND ShippedDate < '1996-09-30 00:00:00')), (COUNT(orderid where CompanyName = 'united Package' and ShippedDate >= '1996-01-01 00:00:00' AND ShippedDate < '1997-01-01 00:00:00')) as percentage;
Question: Of all the shipments made by United Package throughout the year 1996, what percentage correspond to the month of September?
SQL: SELECT cast(count(CASE WHEN orders.shippeddate LIKE '1996-09%' THEN 1 ELSE NULL END) AS REAL) * 100 / count(orders.shipvia) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'United Package' AND orders.shippeddate LIKE '1996%'
Database: retail_world
Note: owners in Mexico refer to ContactTitle where country = 'Mexico';
Question: How many owners are located in Mexico?
SQL: SELECT count(contacttitle) FROM customers WHERE country = 'Mexico' AND contacttitle = 'Owner'
Database: retail_world
Note: full address includes address, city, Region, postalcode and country; contactname = 'Andr Fonseca';
Question: What is the full address of Andr Fonseca?
SQL: SELECT address, city, region, postalcode, country FROM customers WHERE contactname = 'Andr Fonseca'
Database: retail_world
Note: phone area code as 171 refers to phone LIKE '(171)%'; companies refer to CompanyName;
Question: What are the companies that have the same phone area code as 171?
SQL: SELECT companyname FROM customers WHERE phone LIKE '(171)%'
Database: retail_world
Note: SUBTRACT(COUNT(employeeid where country = 'UK' and Title = 'sales representative'), COUNT(employeeid where country = 'USA' and Title = 'sales representative'));
Question: What is the difference in the number of employees from the UK and the USA who work as sales representatives?
SQL: SELECT ( SELECT count(title) FROM employees WHERE country = 'UK' AND title = 'Sales Representative' ) - ( SELECT count(title) FROM employees WHERE country = 'USA' AND title = 'Sales Representative' ) AS difference
Database: retail_world
Note: sales associates refer to ContactTitle; Sao Paulo is the name of the city in the country Brazil;
Question: How many sales associates are located in Sao Paulo, Brazil?
SQL: SELECT count(customerid) FROM customers WHERE city = 'Sao Paulo' AND country = 'Brazil' AND contacttitle = 'Sales Associate'
Database: retail_world
Note: order 10521 refers to orderid = 10521; customerid = 'CACTU'; family name refers to lastname;
Question: What is the family name of the employee who shipped the order 10521 to CACTU?
SQL: SELECT employees.lastname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10521 AND orders.customerid = 'CACTU'
Database: retail_world
Note: Alfreds Futterkiste is the name of the company; order number 10692 refers to orderid = 10692;
Question: What is the shipping cost for order number 10692 from the company Alfreds Futterkiste?
SQL: SELECT orders.freight FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.orderid = 10692 AND customers.companyname = 'Alfreds Futterkiste'
Database: retail_world
Note: order number 10558 refers to orderid = 10558;
Question: What is the shipping company for order number 10558?
SQL: SELECT shippers.companyname FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.orderid = 10558
Database: retail_world
Note: Speedy Express is the name of the shipping company; three order numbers refer to orderid LIMIT 3;
Question: Please list any three order numbers that have been shipped using Speedy Express.
SQL: SELECT orders.orderid FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Speedy Express' LIMIT 3
Database: retail_world
Note: products belong to beverage category refer to productname where categoryname = 'beverage';
Question: What are the products that belong to the beverage category?
SQL: SELECT products.productname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE categories.categoryname = 'Beverages'
Database: retail_world
Note: tofu is the name of the product;
Question: What is the description of the category that tofu belongs to?
SQL: SELECT categories.description FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE products.productname = 'tofu'
Database: retail_world
Note: Gula Malacca is the name of the product; company refers to CompanyName;
Question: Which company supplies Gula Malacca?
SQL: SELECT suppliers.companyname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Gula Malacca'
Database: retail_world
Note: Aux joyeux ecclsiastiques is the name of supply company; products refer to productname;
Question: What are the products that are supplied by Aux joyeux ecclsiastiques?
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Aux joyeux ecclsiastiques'
Database: retail_world
Note: Mayumi's is the name of the company; how much per unit of Konbu refers to unitprice where productname = 'Konbu';
Question: How much per unit of Konbu does Mayumi's charge?
SQL: SELECT products.unitprice FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname LIKE 'Mayumi%' AND products.productname = 'Konbu'
Database: retail_world
Note: Camembert Pierrot is the name of the product; person to contact refers to contactname;
Question: Who is the person to contact to get Camembert Pierrot?
SQL: SELECT suppliers.contactname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Camembert Pierrot'
Database: retail_world
Note: three products that have been discontinued refer to productname LIMIT 3 where Discontinued = 1; categoryname = 'Meat/Poultry';
Question: Please name any three products that have been discontinued in the meat or poultry category.
SQL: SELECT products.productname FROM categories INNER JOIN products ON categories.categoryid = products.categoryid WHERE products.discontinued = 1 AND categories.categoryname = 'Meat/Poultry' LIMIT 3
Database: retail_world
Note: High reorder level generally means high user satisfaction; the highest satisfaction levels refer to MAX(ReorderLevel); two products refer to productname LIMIT 2; CompanyName = 'Heli Swaren GmbH & Co. KG';
Question: Please name any two products that have the highest satisfaction levels among users of Heli Swaren GmbH & Co. KG.
SQL: SELECT products.productname FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE suppliers.companyname = 'Heli Swaren GmbH & Co. KG' ORDER BY products.reorderlevel DESC LIMIT 2
Database: retail_world
Note: Heli Swaren GmbH & Co. KG is the name of the company; who is representing refers to contactname;
Question: Who is the one representing the company "Heli Swaren GmbH & Co. KG"?
SQL: SELECT contactname FROM suppliers WHERE companyname = 'Heli Swaren GmbH & Co. KG'
Database: retail_world
Note: Drachenblut Delikatessen is the company name;
Question: From which country is the company "Drachenblut Delikatessen" from?
SQL: SELECT country FROM customers WHERE companyname = 'Drachenblut Delikatessen'
Database: retail_world
Question: How many territories are there?
SQL: SELECT count(territoryid) FROM territories
Database: retail_world
Note: the largest total price for an order can be calculated as MAX(MULTIPLY(unitprice, quantity, SUBTRACT(1-Discount)));
Question: What is the largest total price for an order?
SQL: SELECT sum(unitprice) FROM `order details` GROUP BY orderid ORDER BY sum(unitprice) DESC LIMIT 1
Database: retail_world
Note: most expensive product refers to productname where MAX(unitprice);
Question: Which product is the most expensive?
SQL: SELECT productname FROM products WHERE unitprice = ( SELECT max(unitprice) FROM products )
Database: retail_world
Note: shipped to France refers to Shipcountry = 'France';
Question: How many of the orders are shipped to France?
SQL: SELECT count(shipcountry) FROM orders WHERE shipcountry = 'France'
Database: retail_world
Note: Hoffman Estates refer to Territorydescription;
Question: Which region does Hoffman Estates belong to?
SQL: SELECT region.regiondescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE territories.territorydescription = 'Hoffman Estates'
Database: retail_world
Note: productname = 'Thringer Rostbratwurst';
Question: What is the homepage link for the company that supplies the product "Thringer Rostbratwurst"?
SQL: SELECT suppliers.homepage FROM products INNER JOIN suppliers ON products.supplierid = suppliers.supplierid WHERE products.productname = 'Thringer Rostbratwurst'
Database: retail_world
Note: ship to the city of "Reims" refers to Shipcity = Reims';
Question: List the first names of the employees who take the orders that ship to the city of "Reims".
SQL: SELECT DISTINCT employees.firstname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.shipcity = 'Reims'
Database: retail_world
Note: the largest quantity of "Manjimup Dried Apples" refers to MAX(quantity) where productname = 'Manjimup Dried Apples';
Question: What is the largest quantity of "Manjimup Dried Apples" for an order?
SQL: SELECT order details.quantity FROM products INNER JOIN `order details` ON order details.productid = products.productid WHERE products.productname = 'Manjimup Dried Apples' ORDER BY order details.quantity DESC LIMIT 1
Database: retail_world
Note: "Speedy Express" is the name of the shipping company; orders refer to orderid;
Question: How many orders were shipped by "Speedy Express"?
SQL: SELECT count(orders.orderid) FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE shippers.companyname = 'Speedy Express'