1sf/bird-sql-train-with-schema huggingface dataset:
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Give the number of Moroccan customers whose account is in debt.
Evidence: account is in debt if c_acctbal < 0; Moroccan customers refer to c_name WHERE n_name = 'MOROCCO';
SQL: SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'MOROCCO' AND T1.c_acctbal < 0
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: For the order with the total price of 231499.38, what was the discounted price for supplier No. 9397?
Evidence: MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)) where o_totalprice = 231499.38 AND l_suppkey = 9397;
SQL: SELECT T1.l_extendedprice * (1 - T1.l_discount) AS DISCOUNTERPRICE FROM lineitem AS T1 INNER JOIN orders AS T2 ON T2.o_orderkey = T1.l_orderkey WHERE T1.l_suppkey = 9397 AND T2.o_totalprice = 231499.38
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id.
Evidence: 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;
SQL: SELECT T2.l_suppkey FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_totalprice = 218195.43 AND T2.l_returnflag = 'R'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
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?
Evidence: 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';
SQL: SELECT T2.l_extendedprice * (1 - T2.l_discount) * (1 + T2.l_tax) AS num FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_clerk = 'Clerk#000000936' AND T2.l_shipmode = 'TRUCK' AND T1.o_orderstatus = '4-NOT SPECIFIED' AND T1.o_orderdate = '1995-03-13'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Customer No.129301 made an order on 1996/7/27, what was the delivery time for the first part of that order?
Evidence: SUBTRACT(l_receiptdate, l_commitdate) WHERE o_orderdate = '1996-07-27' AND o_custkey = '129301';
SQL: SELECT JULIANDAY(T2.l_receiptdate) - JULIANDAY(T2.l_commitdate) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_custkey = '129301' AND T1.o_orderdate = '1996-07-27'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10.
Evidence: name of the customer refers to c_name; o_clerk = 'Clerk#000000803'; order on 1997/12/10 refers to o_orderdate = '1997-12-10';
SQL: SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderdate = '1997-12-10' AND T1.o_clerk = 'Clerk#000000803'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Calculates the profit processed by Supplier No. 7414 on order No. 817154.
Evidence: SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) WHERE l_suppkey = 7414 AND l_orderkey = 817154;
SQL: SELECT T1.l_extendedprice * (1 - T1.l_discount) - T2.ps_supplycost * T1.l_quantity FROM lineitem AS T1 INNER JOIN partsupp AS T2 ON T1.l_suppkey = T2.ps_suppkey WHERE T1.l_suppkey = 7414 AND T1.l_orderkey = 817154
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Which country has the most number of suppliers whose account is in debt?
Evidence: country refers to n_name; the most number of suppliers whose account is in debt refers to MAX(SUM(s_acctbal < 0));
SQL: SELECT T.n_name FROM ( SELECT T2.n_name, SUM(T1.s_acctbal) AS num FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 GROUP BY T2.n_name ) AS T ORDER BY T.num LIMIT 1
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: What is the percentage of the European countries among the given countries?
Evidence: DIVIDE(COUNT(n_name where r_name = 'EUROPE'), COUNT(n_name)) as percentage;
SQL: SELECT CAST(SUM(IIF(T2.r_name = 'EUROPE', 1, 0)) AS REAL) * 100 / COUNT(T1.n_name) FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: Give the percentage of Japanese suppliers whose account is in debt.
Evidence: account is in debt if s_acctbal < 0; DIVIDE(COUNT(s_acctbal < 0 where n_name = 'JAPAN'), COUNT(s_name where n_name = 'JAPAN')) as percentage;
SQL: SELECT CAST(SUM(IIF(T2.n_name = 'JAPAN', 1, 0)) AS REAL) * 100 / COUNT(T1.s_name) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: What is the name of the customer with the highest amount of debt?
Evidence: customer with the highest amount of debt refers to c_name where MIN(c_acctbal);
SQL: SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: How many orders were shipped in 1998?
Evidence: orders refer to l_orderkey; shipped in 1998 refers to year(l_shipdate) = 1998;
SQL: SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%Y', l_shipdate) = '1998'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: How many customers are in debt?
Evidence: customers are in debt refer to c_custkey where c_acctbal < 0;
SQL: SELECT COUNT(c_custkey) FROM customer WHERE c_acctbal < 0
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: How many items that were shipped via air were returned in 1994?
Evidence: items refer to l_linenumber; shipped via air in 1994 refers to year(l_shipdate) = 1994 where l_shipmode = 'AIR'; returned refer to l_returnflag = 'R';
SQL: SELECT COUNT(l_linenumber) FROM lineitem WHERE l_returnflag = 'R' AND l_shipmode = 'AIR' AND STRFTIME('%Y', l_shipdate) = '1994'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: How many customers are in the automobile market segment?
Evidence: automobile market segment refers to c_mktsegment = 'AUTOMOBILE';
SQL: SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'AUTOMOBILE'
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: What are the top 2 order keys of the item with the highest amount of extended price?
Evidence: the highest amount of extended price refers to MAX(l_extendedprice);
SQL: SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice DESC LIMIT 2
Database: retails
Tables: customer, lineitem, nation, orders, part, partsupp, region, supplier
Columns (table index, column name): -1, *, 0, c_custkey, 0, c_mktsegment, 0, c_nationkey, 0, c_name, 0, c_address, 0, c_phone, 0, c_acctbal, 0, c_comment, 1, l_shipdate, 1, l_orderkey, 1, l_discount, 1, l_extendedprice, 1, l_suppkey, 1, l_quantity, 1, l_returnflag, 1, l_partkey, 1, l_linestatus, 1, l_tax, 1, l_commitdate, 1, l_receiptdate, 1, l_shipmode, 1, l_linenumber, 1, l_shipinstruct, 1, l_comment, 2, n_nationkey, 2, n_name, 2, n_regionkey, 2, n_comment, 3, o_orderdate, 3, o_orderkey, 3, o_custkey, 3, o_orderpriority, 3, o_shippriority, 3, o_clerk, 3, o_orderstatus, 3, o_totalprice, 3, o_comment, 4, p_partkey, 4, p_type, 4, p_size, 4, p_brand, 4, p_name, 4, p_container, 4, p_mfgr, 4, p_retailprice, 4, p_comment, 5, ps_partkey, 5, ps_suppkey, 5, ps_supplycost, 5, ps_availqty, 5, ps_comment, 6, r_regionkey, 6, r_name, 6, r_comment, 7, s_suppkey, 7, s_nationkey, 7, s_comment, 7, s_name, 7, s_address, 7, s_phone, 7, s_acctbal
Question: When was the order with the highest amount of total price shipped?
Evidence: when shipped refers to l_shipdate; the highest amount of total price refers to MAX(o_totalprice);
SQL: SELECT T2.l_shipdate FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey ORDER BY T1.o_totalprice DESC LIMIT 1