Chinastark/bird_dataset huggingface dataset:
Database: retails
Note: AVG(l_linenumber) where l_shipdate between '1994-01-01' and '1994-01-30';
Question: What is the average number of items shipped each day in April of 1994?
SQL: SELECT avg(l_linenumber) FROM lineitem WHERE l_shipdate BETWEEN '1994-01-01' AND '1994-01-30'
Database: retails
Note: orders with a total price between 200000 and 300000 refer to o_totalprice between 200000 and 300000;
Question: List the order key of the orders with a total price between 200000 and 300000.
SQL: SELECT o_orderkey FROM orders WHERE o_totalprice BETWEEN 200000 AND 300000
Database: retails
Note: part key of the parts which has an above-average retail price refer to p_partkey where p_retailprice > AVG(p_retailprice);
Question: Find and list the part key of the parts which has an above-average retail price.
SQL: SELECT p_partkey FROM part WHERE p_retailprice > ( SELECT avg(p_retailprice) FROM part )
Database: retails
Note: DIVIDE(COUNT(ps_suppkey where ps_supplycost > 500)), COUNT(ps_suppkey) as percentage;
Question: Calculate the percentage of part supply that costs more than 500.
SQL: SELECT cast(sum(iif(ps_supplycost > 500, 1, 0)) AS REAL) * 100 / count(ps_suppkey) FROM partsupp
Database: retails
Note: supply key refers to s_suppkey; the most amount account balance refers to MAX(s_acctbal);
Question: Find the supply key of the top ten suppliers with the most account balance, and list the supply key along with the account balance in descending order of account balance.
SQL: SELECT s_suppkey, s_acctbal FROM supplier ORDER BY s_acctbal DESC LIMIT 10
Database: retails
Note: customers who are not in debt refer to c_custkey where c_acctbal > 0; the order is urgent if o_orderpriority = '1-URGENT' ;
Question: How many customers who are not in debt ordered an urgent order?
SQL: SELECT count(customer.c_custkey) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_acctbal > 0 AND orders.o_orderpriority = '1-URGENT'
Database: retails
Note: name of customer refers to c_name; phone number of customer refers to c_phone; customers in India who have an above-average account balance refer to n_name = 'INDIA' and c_acctbal > AVG(c_acctbal);
Question: List the name and phone number of customers in India who have an above-average account balance.
SQL: SELECT customer.c_name, customer.c_phone FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_acctbal > ( SELECT avg(c_acctbal) FROM customer ) ORDER BY customer.c_name
Database: retails
Note: supplier#000000654 is the name of the supplier which refers to s_name; parts with the most supply cost refer to ps_partkey where MAX(ps_supplycost);
Question: In the parts supply by Supplier#000000654, list the top five parts with the most supply cost in descending order of supply cost.
SQL: SELECT partsupp.ps_partkey FROM supplier INNER JOIN partsupp ON supplier.s_suppkey = partsupp.ps_suppkey WHERE supplier.s_name = 'Supplier#000000654' ORDER BY partsupp.ps_supplycost DESC LIMIT 5
Database: retails
Note: DIVIDE(COUNT(c_name where c_mktsegment = 'AUTOMOBILE' and n_name = 'FRANCE'), COUNT(c_name where n_name = 'FRANCE')) as percentage;
Question: What percentage of customers from France is in the automobile segment?
SQL: SELECT cast(sum(iif(customer.c_mktsegment = 'AUTOMOBILE', 1, 0)) AS REAL) * 100 / count(customer.c_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'FRANCE'
Database: retails
Note: profit can be calculated as SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))); part which is most profitable refers to p_name where MAX(profit);
Question: Name the part which is most profitable.
SQL: SELECT t.p_name FROM ( SELECT part.p_name , lineitem.l_extendedprice * (1 - lineitem.l_discount) - partsupp.ps_supplycost * lineitem.l_quantity AS num FROM partsupp INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey ) AS t ORDER BY t.num DESC LIMIT 1
Database: retails
Note: the names of countries with the below-average number of customers refer to n_name where COUNT(c_name) < DIVIDE(COUNT(c_name)), COUNT(n_name);
Question: List the names of the countries with the below-average number of customers in ascending order of customer numbers.
SQL: SELECT nation.n_name FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey GROUP BY nation.n_name HAVING count(customer.c_name) > ( SELECT count(customer.c_name) / count(DISTINCT nation.n_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey ) ORDER BY count(customer.c_name)
Database: retails
Note: DIVIDE(COUNT(c_custkey where c_mktsegment = 'HOUSEHOLD' and r_name = 'AFRICA'), COUNT(c_custkey where r_name = 'AFRICA')) as percentage;
Question: What percentage of customers from the African region is in the household segment?
SQL: SELECT cast(sum(iif(region.r_name = 'AFRICA', 1, 0)) AS REAL) * 100 / count(nation.n_nationkey) FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey WHERE customer.c_mktsegment = 'HOUSEHOLD'
Database: retails
Note: items with the most quantity available refer to p_name where MAX(ps_availqty);
Question: List the name of the top ten items with the most quantity available in the descending order of availability.
SQL: SELECT part.p_name FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey ORDER BY partsupp.ps_availqty DESC LIMIT 10
Database: retails
Note: SUBTRACT(DIVIDE(SUM(p_retailprice where l_shipmode = 'SHIP'), COUNT(l_shipmode = 'SHIP')), DIVIDE(SUM(p_retailprice where l_shipmode = 'AIR'), COUNT(l_shipmode = 'AIR')));
Question: Calculate the difference in the average retail price of parts shipped via ship and air.
SQL: SELECT (cast(sum(iif(lineitem.l_shipmode = 'SHIP', part.p_retailprice, 0)) AS REAL) / sum(iif(lineitem.l_shipmode = 'SHIP', 1, 0))) - (cast(sum(iif(lineitem.l_shipmode = 'AIR', part.p_retailprice, 0)) AS REAL) / sum(iif(lineitem.l_shipmode = 'AIR', 1, 0))) FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey
Database: retails
Note: DIVIDE(SUM(l_discount), COUNT(l_partkey)) where p_mfgr = 'Manufacturer#5';
Question: What is the average discount for the parts made by Manufacturer#5?
SQL: SELECT avg(lineitem.l_discount) FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey WHERE part.p_mfgr = 'Manufacturer#5'
Database: retails
Note: parts shipped by rail refer to l_partkey where l_shipmode = 'RAIL'; medium priority refers to o_orderpriority = '3-MEDIUM';
Question: In the parts shipped by rail, how many are of medium priority?
SQL: SELECT count(lineitem.l_partkey) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE lineitem.l_shipmode = 'RAIL' AND orders.o_orderpriority = '3-MEDIUM'
Database: retails
Note: DIVIDE(COUNT(s_acctbal < AVG(s_acctbal)), COUNT(s_suppkey)) as percentage where r_name = 'EUROPE';
Question: Among the suppliers in the European region, what percentage have a below-average account balance?
SQL: SELECT cast(sum(iif(supplier.s_acctbal < ( SELECT avg(supplier.s_acctbal) FROM supplier ), 1, 0)) AS REAL) * 100 / count(nation.n_nationkey) FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey INNER JOIN supplier ON nation.n_nationkey = supplier.s_nationkey WHERE region.r_name = 'EUROPE'
Database: retails
Note: SUBTRACT(DIVIDE(SUM(l_orderkey where year(l_shipdate) = 1995), 12), DIVIDE(SUM(l_orderkey where year(l_shipdate) = 1996), 12)) where o_orderpriority = '5-LOW';
Question: Calculate the difference in the average number of low-priority orders shipped by truck in each month of 1995 and 1996.
SQL: SELECT (cast(sum(iif(strftime('%Y', lineitem.l_shipdate) = 1995, 1, 0)) AS REAL) / 12) - (cast(sum(iif(strftime('%Y', lineitem.l_shipdate) = 1996, 1, 0)) AS REAL) / 12) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_orderpriority = '5-LOW' AND lineitem.l_shipmode = 'TRUCK'
Database: retails
Note: customers who have a debt balance refer to c_custkey where c_acctbal < 0;
Question: List by their id all customers who have a debit balance in their accounts.
SQL: SELECT c_custkey FROM customer WHERE c_acctbal < 0
Database: retails
Note: order number refers to l_orderkey; the lowest price after applying the discount refers to MIN(MULTIPLY(l_extendedprice), SUBTRACT(1, l_discount));
Question: List by order number the 3 items with the lowest price after applying the discount.
SQL: SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice * (1 - l_discount) LIMIT 3
Database: retails
Note: more than 10 items have been returned refer to l_returnflag = 'R' where l_quantity > 10; orders refer to l_orderkey;
Question: How many orders of more than 10 items have been returned?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_quantity > 10 AND l_returnflag = 'R'
Database: retails
Note: SUM(MULTIPLY(MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)), SUM(1, l_tax))) where l_shipmode = 'AIR' and l_shipinstruct = 'NONE';
Question: What is the total price charged for orders shipped by air without shipping instructions?
SQL: SELECT l_extendedprice * (1 - l_discount) * (1 + l_tax) AS totalprice FROM lineitem WHERE l_shipmode = 'AIR' AND l_shipinstruct = 'NONE'
Database: retails
Note: an urgent priority order refers to o_orderkey where o_orderpriority = '1-URGENT'; earlier orderdate have higher priority in delivery; lower delivery priority refers to MAX(o_orderdate);
Question: Of the orders with a lower delivery priority, how many have an urgent priority order?
SQL: SELECT count(o_orderkey) FROM orders WHERE o_orderpriority = '1-URGENT' GROUP BY o_orderdate ORDER BY o_orderdate DESC LIMIT 1
Database: retails
Note: suppliers refer to s_suppkey; Egypt is the name of the nation which refers to n_name = 'EGYPT'; the balance is in debt if s_acctbal < 0;
Question: How many suppliers from Egypt have a debit balance?
SQL: SELECT count(supplier.s_suppkey) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_acctbal < 0 AND nation.n_name = 'EGYPT'
Database: retails
Note: items shipped by REG AIR refer to l_linenumber where l_shipmode = 'REG AIR'; ordered on March 22, 1995 refers to o_orderdate = '1995-03-22';
Question: How many items shipped by REG AIR were ordered on March 22, 1995?
SQL: SELECT count(orders.o_orderkey) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE lineitem.l_shipmode = 'REG AIR' AND orders.o_orderdate = '1995-03-22'
Database: retails
Note: European suppliers refer to s_suppkey where r_name = 'EUROPE';
Question: How many European suppliers are there?
SQL: SELECT count(nation.n_nationkey) FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey INNER JOIN supplier ON nation.n_nationkey = supplier.s_nationkey WHERE region.r_name = 'EUROPE'
Database: retails
Note: segment refers to c_mktsegment; customer made the most orders in April 1994 refers to c_custkey where o_orderdate LIKE '1994-04-%' and MAX(COUNT(o_orderkey));
Question: To which segment belongs the customer that made the most orders in April 1994?
SQL: SELECT t.c_mktsegment FROM ( SELECT customer.c_mktsegment, count(orders.o_orderkey) AS num FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE orders.o_orderdate LIKE '1994-04-%' GROUP BY orders.o_custkey ) AS t ORDER BY t.num DESC LIMIT 1
Database: retails
Note: part refers to p_name; supplier#000000034 refers to s_name = 'supplier#000000034';
Question: Lists all parts supplied by Supplier#000000034.
SQL: SELECT part.p_name FROM partsupp INNER JOIN supplier ON partsupp.ps_suppkey = supplier.s_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE supplier.s_name = 'Supplier#000000034'
Database: retails
Note: cost price refers to ps_supplycost; large burnished copper refers to p_type = 'LARGE BURNISHED COPPER';
Question: What are the cost prices of large burnished copper?
SQL: SELECT partsupp.ps_supplycost FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey WHERE part.p_type = 'LARGE BURNISHED COPPER'
Database: retails
Note: Mozambique refers to n_name = 'MOZAMBIQUE'; low priority order refers to o_orderpriority = '5-LOW';
Question: How many clients from Mozambique required orders with a low priority order?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey INNER JOIN orders ON customer.c_custkey = orders.o_custkey WHERE nation.n_name = 'MOZAMBIQUE' AND orders.o_orderpriority = '5-LOW'
Database: retails
Note: name of the product refers to p_name; close to being sold out refers to ps_availqty < 10; the lowest cost price refers to min(ps_supplycost);
Question: Indicate the name of the product that is close to being sold out and that has the lowest cost price.
SQL: SELECT part.p_name FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey WHERE partsupp.ps_availqty < 10 ORDER BY partsupp.ps_supplycost LIMIT 1
Database: retails
Note: clerk who have served the customer refers to o_clerk;
Question: How many different clerks have served the customer with the address uFTe2u518et8Q8UC?
SQL: SELECT count(orders.o_clerk) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_address = 'uFTe2u518et8Q8UC'
Database: retails
Note: name of the part refers to p_name; without discount refers to l_discount = 0.0000;
Question: Indicate the name of the parts without discount.
SQL: SELECT part.p_name FROM partsupp INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE lineitem.l_discount = 0.0000
Database: retails
Note: Germany is nation name which refers to n_name = 'GERMANY'; comment with 'carefully regular packages' refers to s_comment LIKE 'carefully regular packages%';
Question: How many suppliers from Germany have left a comment with 'carefully regular packages'?
SQL: SELECT count(supplier.s_suppkey) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE nation.n_name = 'GERMANY' AND supplier.s_comment LIKE '%carefully regular packages%'
Database: retails
Note: shipped on 19/11/1994 refers to l_shipdate = '1994-11-19'; ordered on 21/09/1994 refers to o_orderdate = '1994-09-21';
Question: How many products shipped on 19/11/1994 were ordered on 21/09/1994?
SQL: SELECT count(lineitem.l_partkey) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_orderdate = '1994-09-21' AND lineitem.l_shipdate = '1994-11-19'
Database: retails
Note: prom brushed steel refers to p_type = 'PROMO BRUSHED STEEL'; average profit = divide(sum(subtract(multiply(l_extendedprice, subtract(1, l_discount)), multiply(ps_supplycost, l_quantity))), count(ps_partkey));
Question: Calculate the average profit of prom brushed steel products.
SQL: SELECT sum(lineitem.l_extendedprice * (1 - lineitem.l_discount) - partsupp.ps_supplycost * lineitem.l_quantity) / count(partsupp.ps_partkey) FROM partsupp INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE part.p_type = 'PROMO BRUSHED STEEL'
Database: retails
Note: the household segment refers to c_mktsegment = 'HOUSEHOLD'; Iran is nation name which refers to n_name = 'IRAN'; percentage = divide(count(c_custkey where n_name = 'IRAN'), count(c_custkey)) where c_mktsegment = 'HOUSEHOLD' * 100%;
Question: What percentage of customers engaged in the household segment are from Iran?
SQL: SELECT cast(sum(iif(nation.n_name = 'IRAN', 1, 0)) AS REAL) * 100 / count(nation.n_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_mktsegment = 'HOUSEHOLD'
Database: retails
Note: segment refers to c_mktsegment; name refers to c_name; address refers to c_address; phone number refers to c_phone; customer number 3 refers to c_custkey = 3;
Question: Please state the segment, the name, the address, and the phone number of customer number 3.
SQL: SELECT c_mktsegment, c_name, c_address, c_phone FROM customer WHERE c_custkey = 3
Database: retails
Note: line item number refers to l_linenumber; 10% off refers to l_discount = 0.1;
Question: Please list any three line item numbers that have 10% off.
SQL: SELECT l_linenumber FROM lineitem WHERE l_discount = 0.1 LIMIT 3
Database: retails
Note: quantity greater than 40 refers to l_quantity > 40; shipped by air refers to l_shipmode = 'AIR';
Question: How many of the line items that have a quantity greater than 40 have been shipped by air?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_quantity > 40 AND l_shipmode = 'AIR'
Database: retails
Note: ship mode refers to l_shipmode; "deliver in person" instruction refers to l_shipinstruct = 'DELIVER IN PERSON';
Question: Which ship mode has more "deliver in person" instructions, rail or mail?
SQL: SELECT iif(sum(iif(l_shipmode = 'RAIL', 1, 0)) - sum(iif(l_shipmode = 'MAIL', 1, 0)), 'RAIL', 'MAIL') AS RESULT FROM lineitem WHERE l_shipinstruct = 'DELIVER IN PERSON'
Database: retails
Note: total price refers to o_totalprice; order priority refers to o_orderpriority; order number 33 refers to o_orderkey = 33;
Question: What is the total price and the order priority of order number 33?
SQL: SELECT o_totalprice, o_orderpriority FROM orders WHERE o_orderkey = 33
Database: retails
Note: 1998 refers to year(o_orderdate) = '1998'; a total price under 950 refers to o_totalprice < 950;
Question: How many orders in 1998 had a total price under 950?
SQL: SELECT count(o_orderkey) AS countorders FROM orders WHERE strftime('%Y', o_orderdate) = '1998' AND o_totalprice < 950
Database: retails
Note: customer refers to c_name; with debt refers to c_acctbal < 0;
Question: Please list any three customers with debt.
SQL: SELECT c_name FROM customer WHERE c_acctbal < 0 LIMIT 3
Database: retails
Note: discounted price refers to multiply(l_extendedprice, subtract(1, l_discount)); line item number 1 refers to l_linenumber = 1;
Question: What is the discounted price of line item number 1?
SQL: SELECT l_extendedprice * (1 - l_discount) FROM lineitem WHERE l_linenumber = 1
Database: retails
Note: full price of under 16947.7 refers to l_extendedprice < 16947.7; returned item refers to l_returnflag = 'R'; not returned item refers to l_returnflag = 'A' OR l_returnflag = 'N'; difference = subtract(count(l_linenumber where l_returnflag = 'A' OR l_returnflag = 'N'), count(l_linenumber where l_returnflag = 'R')) where l_extendedprice < 16947.7;
Question: What is the difference between the number of returned items and not returned items with the full price of under 16947.7?
SQL: SELECT sum(iif(l_returnflag = 'A', 1, 0)) - sum(iif(l_returnflag = 'N', 1, 0)) AS diff FROM lineitem WHERE l_extendedprice < 16947.7
Database: retails
Note: supply cost refers to ps_supplycost; large plated tin refers to p_type = 'large plated tin';
Question: What is the supply cost of large plated tin?
SQL: SELECT partsupp.ps_supplycost FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey WHERE part.p_type = 'large plated tin'
Database: retails
Note: part name refers to p_name; an available quantity of more than 9998 refers to ps_availqty > 9998;
Question: Please name any three parts that have an available quantity of more than 9998.
SQL: SELECT part.p_name FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey WHERE partsupp.ps_availqty > 9998 LIMIT 3
Database: retails
Note: part name refers to p_name; wrap bag container refers to p_container = 'WRAP BAG'; supply cost of under 10 refers to ps_supplycost < 10;
Question: Please list any two parts that come with the wrap bag container and have a supply cost of under 10.
SQL: SELECT part.p_name FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey WHERE partsupp.ps_supplycost < 10 AND part.p_container = 'WRAP BAG' LIMIT 2
Database: retails
Note: nationality refers to n_name; supplier number 1 refers to s_suppkey = 1;
Question: What is the nationality of supplier number 1?
SQL: SELECT nation.n_name FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_suppkey = 1
Database: retails
Note: country is nation name which refers to n_name; Africa is region name refers to r_name = 'Africa';
Question: What are the countries that belong to Africa?
SQL: SELECT nation.n_name FROM region INNER JOIN nation ON region.r_regionkey = nation.n_regionkey WHERE region.r_name = 'Africa'
Database: retails
Note: region refers to has r_name; the lowest number of countries refers to min(count(n_name));
Question: Which region has the lowest number of countries?
SQL: SELECT t.r_name FROM ( SELECT region.r_name, count(nation.n_name) AS num FROM region INNER JOIN nation ON region.r_regionkey = nation.n_regionkey GROUP BY region.r_name ) AS t ORDER BY t.num LIMIT 1
Database: retails
Note: furniture segment refers to c_mktsegment = 'FURNITURE'; Iraq refers to n_name = 'Iraq';
Question: How many customers from the furniture segments come from Iraq?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_mktsegment = 'FURNITURE' AND nation.n_name = 'IRAQ'
Database: retails
Note: customer name refers to c_name; number 93697 refers to o_custkey = 93697; total order price of 191918.92 refers to o_totalprice = 191918.92;
Question: What is the name of the customer number 93697 with the total order price of 191918.92?
SQL: SELECT customer.c_name FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE orders.o_totalprice = 191918.92 AND orders.o_custkey = 93697
Database: retails
Note: nation refers to n_name; region refers to r_name; customer#000000008 refers to c_name = 'customer#000000008';
Question: Which nation and region does the Customer#000000008 come from?
SQL: SELECT nation.n_name, 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_name = 'Customer#000000008'
Database: retails
Note: delivery time = subtract(l_receiptdate, l_commitdate); clerk refers to o_clerk; order number 6 refers to o_orderkey = 6;
Question: What is the delivery time and the clerk of order number 6?
SQL: SELECT julianday(lineitem.l_receiptdate) - julianday(lineitem.l_commitdate), orders.o_clerk FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE orders.o_orderkey = 6
Database: retails
Note: Japanese refers to n_name = 'Japan'; have accounts in debt refers to s_acctbal < 0;
Question: How many Japanese suppliers have their accounts in debt?
SQL: SELECT count(supplier.s_suppkey) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_acctbal < 0 AND nation.n_name = 'JAPAN'
Database: retails
Note: customer refers to c_name; the most in debt refers to max(c_acctbal);
Question: Which customer is the most in debt?
SQL: SELECT c_name FROM customer WHERE c_acctbal = ( SELECT min(c_acctbal) FROM customer )
Database: retails
Note: date refers to o_orderdate; urgent order refers to o_orderpriority = '1-URGENT';
Question: List all the dates of the urgent orders.
SQL: SELECT o_orderdate FROM orders WHERE o_orderpriority = '1-URGENT'
Database: retails
Note: instructed to be delivered in person refers to l_shipinstruct = 'DELIVER IN PERSON';
Question: How many of the items are instructed to be delivered in person?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_shipinstruct = 'DELIVER IN PERSON'
Database: retails
Note: the largest supplier's account balance refers to max(s_acctbal);
Question: What is the largest supplier's account balance?
SQL: SELECT max(s_acctbal) FROM supplier
Database: retails
Note: close to being out of stock refers to ps_availqty < 10;
Question: How many part supplies are close to being out of stock?
SQL: SELECT count(ps_suppkey) FROM partsupp WHERE ps_availqty < 10