Chinastark/bird_dataset huggingface dataset:
Database: retail_world
Note: regular customer refers to max(count(customerid)); products category refers to categoryname; mostly buy refers to max(count(categoryid));
Question: Which customer is a regular customer in this shop and what are the products category that he mostly buy?
SQL: SELECT orders.customerid, categories.categoryname FROM orders INNER JOIN `order details` ON orders.orderid = order details.orderid INNER JOIN products ON order details.productid = products.productid INNER JOIN categories ON products.categoryid = categories.categoryid ORDER BY orders.customerid DESC, categories.categoryname DESC
Database: retail_world
Note: most popular confections product refers to productid = max(count(MULTIPLY(quantity, unitprice))) from categoryname = 'Confections' ;  total sales refers to sum(MULTIPLY(quantity, unitprice));
Question: What are the most popular confections product and calculate the total sales generated by this product?
SQL: SELECT count(products.unitprice * order details.quantity) FROM products INNER JOIN categories ON products.categoryid = categories.categoryid INNER JOIN `order details` ON products.productid = order details.productid WHERE categories.categoryname = 'Confections' GROUP BY order details.quantity ORDER BY order details.quantity DESC LIMIT 1
Database: retail_world
Note: name of product refers to productname; ID refers to productid;
Question: What is the name of product with the ID of 77?
SQL: SELECT productname FROM products WHERE productid = 77
Database: retail_world
Note: in USA refers to country = 'USA';
Question: State the company name of all suppliers in USA.
SQL: SELECT companyname FROM suppliers WHERE country = 'USA'
Database: retail_world
Question: What is the position title for Laura Callahan?
SQL: SELECT title FROM employees WHERE firstname = 'Laura' AND lastname = 'Callahan'
Database: retail_world
Note: name of employee refers to firstname; from Victuailles en stock refers to CompanyName = 'Victuailles en stock';
Question: State the name of employee that manages the order from Victuailles en stock?
SQL: SELECT DISTINCT employees.firstname, employees.lastname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid INNER JOIN customers ON orders.customerid = customers.customerid WHERE customers.companyname = 'Victuailles en stock'
Database: retail_world
Note: Federal Shipping refers to CompanyName = 'Federal Shipping';
Question: How many orders 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: Morristown refers to Territorydescription = 'Morristown';
Question: Who was taking charge of orders from Morristown?
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 = 'Morristown'
Database: retail_world
Note: name of all territories refers to Territorydescription; Northern region refers to Regiondescription = 'Northern';
Question: State the name of all territories in Northern region.
SQL: SELECT DISTINCT territories.territorydescription FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Northern'
Database: retail_world
Question: How many orders were handled by Michael Suyama. State the order ID.
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: Northern region refers to RegionID = 3; Western region refers to RegionID = 2 ; ratio = divide((Territorydescription where RegionID = 3), (Territorydescription where RegionID = 2));
Question: What is the ratio number of territories in Northern region and number territories in Western region?
SQL: SELECT cast(( SELECT count(territories.territoryid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Northern' ) AS REAL) * 100 / ( SELECT count(territories.territoryid) FROM territories INNER JOIN region ON territories.regionid = region.regionid WHERE region.regiondescription = 'Westerns' ) AS calu
Database: retail_world
Note: territory ID from 1000 to 2000 refers to TerritoryID BETWEEN 1000 and 2000;
Question: Provide employees' ID who are in-charge of territory ID from 1000 to 2000.
SQL: SELECT employeeid FROM employeeterritories WHERE territoryid BETWEEN 1000 AND 2000
Database: retail_world
Note: descriptions refers to Territorydescription; region refers to Regiondescription;
Question: List down the territory IDs, descriptions and region description which are under the in-charge of Nancy Davolio,
SQL: SELECT territories.regionid, 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.lastname = 'Davolio' AND employees.firstname = 'Nancy'
Database: retail_world
Note: Sales Representative refers to Title = 'Sales Representative'；were hired in 1992 refers to HireDate = '1992';
Question: Describe Sales Representative names who were hired in 1992 and compare the number of orders among them.
SQL: SELECT employees.firstname, employees.lastname, count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.title = 'Sales Representative' AND strftime('%Y', employees.hiredate) = '1992' GROUP BY employees.employeeid, employees.firstname, employees.lastname
Database: retail_world
Note: Vegie-spread product refers to productname = 'Vegie-spread'；total payment = MULTIPLY(unitprice, quantity, (1-Discount));
Question: Calculate the total payment of orders for Vegie-spread product.
SQL: SELECT sum(order details.unitprice * order details.quantity * (1 - order details.discount)) AS SUM FROM products INNER JOIN `order details` ON products.productid = order details.productid WHERE products.productname = 'Vegie-spread'
Database: retail_world
Note: products refers to Order_Details.productid; on 14th August, 1996 refers to orderdate = '8/14/1996';
Question: List down the company names which supplied products for the order on 14th August, 1996.
SQL: SELECT suppliers.companyname FROM suppliers INNER JOIN products ON suppliers.supplierid = products.supplierid INNER JOIN `order details` ON products.productid = order details.productid INNER JOIN orders ON order details.orderid = orders.orderid WHERE date(orders.orderdate) = '1996-08-14'
Database: retail_world
Note: suppliers refers to CompanyName; highest in reorder level refers to Max(ReorderLevel);
Question: Among the product lists in order ID 10337, write down the product names and suppliers which had the highest in reorder level.
SQL: SELECT products.productname, suppliers.companyname FROM suppliers INNER JOIN products ON suppliers.supplierid = products.supplierid INNER JOIN `order details` ON products.productid = order details.productid WHERE order details.orderid = 10337 ORDER BY products.reorderlevel DESC LIMIT 1
Database: retail_world
Note: Name the shipper refers to CompanyName; most shipments refers to max(count(orderid)); first quarter of 1998 refers to ShippedDate = 1998/1 and ShippedDate = 1998/2 and ShippedDate = 1998/3 and ShippedDate = 1998/4;
Question: Name the shipper which had the most shipments in first quarter of 1998.
SQL: SELECT shippers.companyname FROM shippers INNER JOIN orders ON shippers.shipperid = orders.shipvia WHERE strftime('%Y', orders.shippeddate) = '1998' GROUP BY shippers.companyname ORDER BY count(orders.orderid) DESC LIMIT 1
Database: retail_world
Note: London refers to city = 'London';
Question: How many customers are located in London?
SQL: SELECT count(customerid) FROM customers WHERE city = 'London'
Database: retail_world
Question: What is the title of Michael Suyama?
SQL: SELECT title FROM employees WHERE firstname = 'Michael' AND lastname = 'Suyama'
Database: retail_world
Note: full name refers to firstname, lastname; brith day refers to birthdate;
Question: List out the full name of employee who has birth day on "3/4/1955 12:00:00 AM".
SQL: SELECT firstname, lastname FROM employees WHERE birthdate = '1955-03-04 00:00:00'
Database: retail_world
Question: Mention the first name of employee who took care the order id 10250.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10250
Database: retail_world
Note: located in Tacoma refers to city = 'Tacoma';
Question: How many orders that the employees who are located in Tacoma handled?
SQL: SELECT count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.city = 'Tacoma'
Database: retail_world
Question: What is the country location of the employee who handled order id 10257?
SQL: SELECT employees.country FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10257
Database: retail_world
Question: What is the title of the employee who handled order id 10270?
SQL: SELECT employees.title FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10257
Database: retail_world
Question: Give the phone number of the customer who placed the order id 10264.
SQL: SELECT customers.phone FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.orderid = 10264
Database: retail_world
Question: What is the region where the customer who placed the order id 10276 located?
SQL: SELECT customers.region FROM customers INNER JOIN orders ON customers.customerid = orders.customerid WHERE orders.orderid = 10276
Database: retail_world
Note: orders to Brazil refers to Shipcountry = 'Brazil'; highest salary refers to max(salary); average salary = AVG(Salary);
Question: Among the employees who handled orders to Brazil, who has the highest salary and calculate the average salary of them.
SQL: SELECT employees.firstname, employees.lastname, avg(employees.salary) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.shipcountry = 'Brazil' GROUP BY employees.firstname, employees.lastname ORDER BY sum(employees.salary) DESC LIMIT 1
Database: retail_world
Note: shipped in 1996 refers to ShippedDate = 1996; percentage salary = divide(sum(Salary when ShippedDate = 1996), sum(Salary)) as percentage;
Question: Calculate the percentage salary of employees who handled orders shipped in 1996.
SQL: SELECT cast(sum(CASE WHEN strftime('%Y', orders.shippeddate) = '1996' THEN employees.salary ELSE 0 END) AS REAL) * 100 / sum(employees.salary) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid
Database: retail_world
Note: When was hired refers to HireDate;
Question: When was the employee who handled order id 10281 hired?
SQL: SELECT employees.hiredate FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10281
Database: retail_world
Note: reported to employee id 5 refers to ReportsTo = 5;
Question: How many orders was handled by employees who reported to employee id 5?
SQL: SELECT count(orders.orderid) FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE employees.reportsto = 5
Database: retail_world
Note: full name refers to firstname, lastname;
Question: Give the full name of employee who handled the order id 10280.
SQL: SELECT employees.firstname, employees.lastname FROM employees INNER JOIN orders ON employees.employeeid = orders.employeeid WHERE orders.orderid = 10280
Database: retail_world
Note: shipping company refers to CompanyName;
Question: State the shipping company of order id 10260.
SQL: SELECT shippers.companyname FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.orderid = 10260
Database: retail_world
Note: shipped through refers to ShipVia; united Package refers to CompanyName = 'united Package';
Question: How many orders have been shipped through 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: shipping company refers to shippers; phone number refers to phone;
Question: List out the phone number of the shipping company of order id 10296.
SQL: SELECT shippers.phone FROM orders INNER JOIN shippers ON orders.shipvia = shippers.shipperid WHERE orders.orderid = 10260
Database: retails
Note: returned refer to l_returnflag = 'R'; order no.5 refers to l_orderkey = 5; kinds of items refer to l_linenumber;
Question: How many kinds of items are returned in order no.5?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_orderkey = 5 AND l_returnflag = 'R'
Database: retails
Note: order no.1 refers to l_orderkey = 1; the latest date shipped refers to MAX(l_shipdate);
Question: When was the latest date the items of order no.1 were shipped?
SQL: SELECT max(l_shipdate) FROM lineitem WHERE l_orderkey = 1
Database: retails
Note: earlier orderdate have higher priority in delivery; which order no. 4 or order no. 36 refers to o_orderkey in (4, 36) where MIN(o_orderdate);
Question: Which order has a higher priority, order no. 4 or order no. 36?
SQL: SELECT l_orderkey FROM lineitem WHERE l_orderkey IN (4, 36) ORDER BY l_shipdate DESC LIMIT 1
Database: retails
Note: the highest total price refers to MAX(o_totalprice); comment of the order refers to o_comment;
Question: What is the comment of the order with the highest total price?
SQL: SELECT o_comment FROM orders WHERE o_totalprice = ( SELECT max(o_totalprice) FROM orders )
Database: retails
Note: customer phone refers to c_phone; customer#000000001 refers to c_name;
Question: What is the phone number of Customer#000000001?
SQL: SELECT c_phone FROM customer WHERE c_name = 'Customer#000000001'
Database: retails
Note: orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD';
Question: How many orders in total have the customers in the household segment made?
SQL: SELECT count(orders.o_orderkey) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_mktsegment = 'HOUSEHOLD'
Database: retails
Note: orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the highest total price refers to MAX(o_totalprice);
Question: Among all the orders made by a customer in the household segment, what is the highest total price?
SQL: SELECT max(orders.o_totalprice) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_mktsegment = 'HOUSEHOLD'
Database: retails
Note: orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; order comments refer to o_comment;
Question: Please list the order comments of all the orders made by customers in the household segment.
SQL: SELECT orders.o_comment FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_mktsegment = 'HOUSEHOLD'
Database: retails
Note: name of the customer refers to c_name; single order with the highest total price refers to MAX(o_totalprice) LIMIT 1;
Question: Please give the name of the customer who has made the single order with the highest total price.
SQL: SELECT customer.c_name FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey ORDER BY orders.o_totalprice DESC LIMIT 1
Database: retails
Note: account is in debt if c_acctbal < 0;
Question: Please list the order keys of all the orders made by a customer whose account is in debt.
SQL: SELECT orders.o_orderkey FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_acctbal < 0
Database: retails
Note: orders in household segment refer to o_orderkey where c_mktsegment = 'HOUSEHOLD'; the order is urgent if o_orderpriority = '1-URGENT' ;
Question: Among the orders made by customers in the household segment, how many of them are urgent?
SQL: SELECT count(orders.o_orderpriority) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_mktsegment = 'HOUSEHOLD' AND orders.o_orderpriority = '1-URGENT'
Database: retails
Note: Brazil is the name of the nation which refers to n_name = 'BRAZIL';
Question: How many customers are in Brazil?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'BRAZIL'
Database: retails
Note: phone numbers refer to c_phone; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; household segment refers to c_mktsegment = 'HOUSEHOLD';
Question: Please list the phone numbers of all the customers in the household segment and are in Brazil.
SQL: SELECT customer.c_phone FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_mktsegment = 'HOUSEHOLD' AND nation.n_name = 'BRAZIL'
Database: retails
Note: Germany is the name of the nation which refers to n_name = 'GERMANY'; account balance of over 1000 refers to c_acctbal > 1000;
Question: Among all the customers in Germany, how many of them have an account balance of over 1000?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'GERMANY' AND customer.c_acctbal > 1000
Database: retails
Note: orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY';
Question: How many orders in total are made by customers in Germany?
SQL: SELECT count(customer.c_custkey) FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN orders ON customer.c_custkey = orders.o_custkey WHERE nation.n_name = 'GERMANY'
Database: retails
Note: orders refer to o_orderkey; total price refers to o_totalprice; Germany is the name of the nation which refers to n_name = 'GERMANY';
Question: What is the total price of all the orders made by customers in Germany?
SQL: SELECT sum(orders.o_totalprice) FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN orders ON customer.c_custkey = orders.o_custkey WHERE nation.n_name = 'GERMANY'
Database: retails
Note: orders refer to o_orderkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; earlier orderdate have higher priority in delivery therefore MIN(o_orderdate);
Question: Among the orders made by customers in Germany, which one of them has the highest priority in delivery? Please give its order key.
SQL: SELECT orders.o_orderkey FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN orders ON customer.c_custkey = orders.o_custkey WHERE nation.n_name = 'GERMANY' ORDER BY orders.o_orderdate LIMIT 1
Database: retails
Note: DIVIDE(SUM(o_totalprice), COUNT(o_orderkey)) where n_name = 'GERMANY';
Question: What is the average price of the orders made by a customer in Germany?
SQL: SELECT avg(orders.o_totalprice) FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN orders ON customer.c_custkey = orders.o_custkey WHERE nation.n_name = 'GERMANY'
Database: retails
Note: DIVIDE(COUNT(c_custkey when n_name = 'GERMANY'), COUNT(c_custkey)) as percentage;
Question: Among all the customers, what is the percentage of the customer's nation being Germany?
SQL: SELECT cast(sum(iif(nation.n_name = 'GERMANY', 1, 0)) AS REAL) * 100 / count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey
Database: retails
Note: No.2 region refers to n_regionkey = 2;
Question: How many countries are there in the No.2 region?
SQL: SELECT count(n_nationkey) FROM nation WHERE n_regionkey = 2
Database: retails
Note: supplier No.34 refers to s_suppkey = 34; country refers to n_name;
Question: Which country does supplier No.34 come from?
SQL: SELECT nation.n_name FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_suppkey = 34
Database: retails
Note: "supplier#000000129" is the name of the supplier which refers to s_name; Which region refers to r_name;
Question: Which region does "Supplier#000000129" belong to?
SQL: SELECT region.r_name FROM nation INNER JOIN supplier ON nation.n_nationkey = supplier.s_nationkey INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE supplier.s_name = 'Supplier#000000129'
Database: retails
Note: "customer#000000055" is the name of the customer which refers to c_name; nationality is the state of belonging to a particular country, therefore nationality refers to n_name;
Question: What is the nationality of "Customer#000000055"?
SQL: SELECT nation.n_name FROM customer INNER JOIN nation ON customer.c_name = 'Customer#000000055'
Database: retails
Note: "customer#000000055" is the name of the customer which refers to c_name; region name refers to r_name;
Question: Give customer No.106936's region name.
SQL: SELECT region.r_name FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE customer.c_custkey = 106936
Database: retails
Note: account is in debt if c_acctbal < 0; Moroccan customers refer to c_name WHERE n_name = 'MOROCCO';
Question: Give the number of Moroccan customers whose account is in debt.
SQL: SELECT count(customer.c_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'MOROCCO' AND customer.c_acctbal < 0
Database: retails
Note: MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)) where o_totalprice = 231499.38 AND l_suppkey = 9397;
Question: For the order with the total price of 231499.38, what was the discounted price for supplier No. 9397?
SQL: SELECT lineitem.l_extendedprice * (1 - lineitem.l_discount) AS discounterprice FROM lineitem INNER JOIN orders ON orders.o_orderkey = lineitem.l_orderkey WHERE lineitem.l_suppkey = 9397 AND orders.o_totalprice = 231499.38
Database: retails
Note: returned item refers to l_returnflag = 'R'; supplier id refers to l_suppkey; order with the total price of 218195.43 refers to o_totalprice = 218195.43;
Question: For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id.
SQL: SELECT lineitem.l_suppkey FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_totalprice = 218195.43 AND lineitem.l_returnflag = 'R'
Database: retails
Note: MULTIPLY(MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)), SUM(1, l_tax)) WHERE o_clerk = 'Clerk#000000936', o_orderstatus = '4-NOT SPECIFIED', o_orderdate = '1995-03-13' AND l_shipmode = 'TRUCK';
Question: Clerk#000000936 dealt with a "Not Specified" order on 1995/3/13, what was the charge for the part of the order shipped by truck?
SQL: SELECT lineitem.l_extendedprice * (1 - lineitem.l_discount) * (1 + lineitem.l_tax) AS num FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_clerk = 'Clerk#000000936' AND lineitem.l_shipmode = 'TRUCK' AND orders.o_orderstatus = '4-NOT SPECIFIED' AND orders.o_orderdate = '1995-03-13'
Database: retails
Note: SUBTRACT(l_receiptdate, l_commitdate) WHERE o_orderdate = '1996-07-27' AND o_custkey = '129301';
Question: Customer No.129301 made an order on 1996/7/27, what was the delivery time for the first part of that order?
SQL: SELECT julianday(lineitem.l_receiptdate) - julianday(lineitem.l_commitdate) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_custkey = '129301' AND orders.o_orderdate = '1996-07-27'
Database: retails
Note: name of the customer refers to c_name; o_clerk = 'Clerk#000000803'; order on 1997/12/10 refers to o_orderdate = '1997-12-10';
Question: Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10.
SQL: SELECT customer.c_name FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE orders.o_orderdate = '1997-12-10' AND orders.o_clerk = 'Clerk#000000803'