input
stringlengths
358
16.1k
output
stringlengths
24
805
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list any three line item numbers that have 10% off. [/INST]
SELECT l_linenumber FROM lineitem WHERE l_discount = 0.1 LIMIT 3;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many of the line items that have a quantity greater than 40 have been shipped by air? [/INST]
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 40 AND l_shipmode = 'AIR';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which ship mode has more "deliver in person" instructions, rail or mail? [/INST]
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';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the total price and the order priority of order number 33? [/INST]
SELECT o_totalprice, o_orderpriority FROM orders WHERE o_orderkey = 33;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many orders in 1998 had a total price under 950? [/INST]
SELECT COUNT(o_orderkey) AS countorders FROM orders WHERE STRFTIME('%Y', o_orderdate) = '1998' AND o_totalprice < 950;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list any three customers with debt. [/INST]
SELECT c_name FROM customer WHERE c_acctbal < 0 LIMIT 3;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the discounted price of line item number 1? [/INST]
SELECT l_extendedprice * (1 - l_discount) FROM lineitem WHERE l_linenumber = 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the difference between the number of returned items and not returned items with the full price of under 16947.7? [/INST]
SELECT SUM(IIF(l_returnflag = 'A', 1, 0)) - SUM(IIF(l_returnflag = 'N', 1, 0)) AS diff FROM lineitem WHERE l_extendedprice < 16947.7;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the supply cost of large plated tin? [/INST]
SELECT T2.ps_supplycost FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T1.p_type = 'large plated tin';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please name any three parts that have an available quantity of more than 9998. [/INST]
SELECT T1.p_name FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T2.ps_availqty > 9998 LIMIT 3;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list any two parts that come with the wrap bag container and have a supply cost of under 10. [/INST]
SELECT T1.p_name FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T2.ps_supplycost < 10 AND T1.p_container = 'WRAP BAG' LIMIT 2;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the nationality of supplier number 1? [/INST]
SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_suppkey = 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What are the countries that belong to Africa? [/INST]
SELECT T2.n_name FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T1.r_name = 'Africa';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which region has the lowest number of countries? [/INST]
SELECT T.r_name FROM ( SELECT T1.r_name, COUNT(T2.n_name) AS num FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey GROUP BY T1.r_name ) AS T ORDER BY T.num LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many customers from the furniture segments come from Iraq? [/INST]
SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'FURNITURE' AND T2.n_name = 'IRAQ';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the customer number 93697 with the total order price of 191918.92? [/INST]
SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice = 191918.92 AND T1.o_custkey = 93697;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which nation and region does the Customer#000000008 come from? [/INST]
SELECT T1.n_name, T3.r_name FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey WHERE T2.c_name = 'Customer#000000008';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the delivery time and the clerk of order number 6? [/INST]
SELECT JULIANDAY(T2.l_receiptdate) - JULIANDAY(T2.l_commitdate), T1.o_clerk FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderkey = 6;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many Japanese suppliers have their accounts in debt? [/INST]
SELECT COUNT(T1.s_suppkey) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 AND T2.n_name = 'JAPAN';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which customer is the most in debt? [/INST]
SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer );
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List all the dates of the urgent orders. [/INST]
SELECT o_orderdate FROM orders WHERE o_orderpriority = '1-URGENT';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many of the items are instructed to be delivered in person? [/INST]
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipinstruct = 'DELIVER IN PERSON';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the largest supplier's account balance? [/INST]
SELECT MAX(s_acctbal) FROM supplier;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many part supplies are close to being out of stock? [/INST]
SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List all the nations in Europe. [/INST]
SELECT T2.n_name FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T1.r_name = 'EUROPE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the supply cost for the part "violet olive rose ivory sandy"? [/INST]
SELECT T2.ps_supplycost FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T1.p_name = 'violet olive rose ivory sandy';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List all the customers' phone numbers from Ethiopia. [/INST]
SELECT T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'Ethiopia';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the total price of all orders from the customer with the phone number "627-220-3983"? [/INST]
SELECT SUM(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_phone = '627-220-3983';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What are the shipping methods for the orders on 12/31/1994? [/INST]
SELECT DISTINCT T2.l_shipmode FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderdate = '1994-12-31';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the account balance of the supplier with the most parts? [/INST]
SELECT T.s_acctbal FROM ( SELECT T1.s_acctbal, COUNT(T2.ps_suppkey) AS num FROM supplier AS T1 INNER JOIN partsupp AS T2 ON T1.s_suppkey = T2.ps_suppkey GROUP BY T1.s_suppkey ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which nation does the supplier with the account balance of "4393.04" belong to? [/INST]
SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal = 4393.04;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the region with the most customers? [/INST]
SELECT T.r_name FROM ( SELECT T3.r_name, COUNT(T2.c_custkey) AS num FROM nation AS T1 INNER JOIN customer AS T2 ON T1.n_nationkey = T2.c_nationkey INNER JOIN region AS T3 ON T1.n_regionkey = T3.r_regionkey GROUP BY T3.r_name ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the phone number of the customer who placed orders with a total price of more than $300,000. [/INST]
SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice > 300000;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What are the clerks of orders with line items shipped by mail? [/INST]
SELECT T1.o_clerk FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'MAIL';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What are the top 5 nations of suppliers with the lowest account balance? [/INST]
SELECT T2.n_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey ORDER BY T1.s_acctbal LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List all the addresses for the suppliers of the biggest parts. [/INST]
SELECT T2.s_address FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey ORDER BY T3.p_size DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which part and supplier have the most profit? [/INST]
SELECT T3.p_name, T4.s_name FROM partsupp AS T1 INNER JOIN lineitem AS T2 ON T1.ps_suppkey = T2.l_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey INNER JOIN supplier AS T4 ON T1.ps_suppkey = T4.s_suppkey ORDER BY T2.l_extendedprice * (1 - T2.l_discount) - T1.ps_supplycost * T2.l_quantity DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What proportion of suppliers are from Asia? [/INST]
SELECT CAST(SUM(IIF(T1.r_name = 'ASIA', 1, 0)) AS REAL) * 100 / COUNT(T1.r_regionkey) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey INNER JOIN supplier AS T3 ON T2.n_nationkey = T3.s_nationkey;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please indicate the total price of order key 32. [/INST]
SELECT o_totalprice FROM orders WHERE o_orderkey = 32;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many order keys are not applied for the discount? [/INST]
SELECT COUNT(l_orderkey) FROM lineitem WHERE l_discount = 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List line items shipped by truck with delivery time before 1997. [/INST]
SELECT l_linenumber FROM lineitem WHERE STRFTIME('%Y', l_shipdate) < 1997 AND l_shipmode = 'truck';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many line items were returned in 1998? [/INST]
SELECT l_linenumber FROM lineitem WHERE STRFTIME('%Y', l_shipdate) < 1997 AND l_shipmode = 'TRUCK';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which line item with the highest quantity is shipped by air? [/INST]
SELECT l_linenumber FROM lineitem WHERE l_shipmode = 'AIR' ORDER BY l_quantity DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the names of customers whose accounts are in debt. [/INST]
SELECT c_name FROM customer WHERE c_acctbal < 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many customers belong to the household segment in Germany? [/INST]
SELECT COUNT(T1.c_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'GERMANY';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the phone numbers of customers whose order priority is urgent. [/INST]
SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderpriority = '1-URGENT';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Name of customer whose order is applied with the highest discount. [/INST]
SELECT T3.c_name FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey INNER JOIN customer AS T3 ON T1.o_custkey = T3.c_custkey ORDER BY T2.l_discount DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the 5 orders with the highest total price, indicating the delivery date. [/INST]
SELECT T1.o_orderkey, 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 5;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the comments describing orders from customers in the furniture segment. [/INST]
SELECT T1.o_comment FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'FURNITURE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please indicate the names of the customers whose order with a total price over $300000. [/INST]
SELECT T2.c_name FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_totalprice > 300000;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Name customers in India with account balances over $5000. [/INST]
SELECT T1.c_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal > 5000 AND T2.n_name = 'INDIA';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: List the phone numbers of suppliers from Japan. [/INST]
SELECT T1.s_phone FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'JAPAN';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the providers in Argentina, which supplier has an account that is in debt? [/INST]
SELECT T1.s_name FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 AND T2.n_name = 'ARGENTINA';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many countries belong to the Algeria region? [/INST]
SELECT COUNT(T1.r_name) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey WHERE T2.n_name = 'ALGERIA';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please indicate the names of customers whose orders are eligible for 10% discount with order dates between 1/1/1994 and 1/1/1995. [/INST]
SELECT T3.c_name FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey INNER JOIN customer AS T3 ON T1.o_custkey = T3.c_custkey WHERE T2.l_discount = 0.1 AND STRFTIME('%Y', T1.o_orderdate) BETWEEN 1994 AND 1995;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Calculate the percentage of countries that belong to the American region. [/INST]
SELECT CAST(SUM(IIF(T1.r_name = 'America', 1, 0)) AS REAL) * 100 / COUNT(T2.n_name) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Calculate percentage of household segment in Indonesia. [/INST]
SELECT CAST(SUM(IIF(T1.c_mktsegment = 'HOUSEHOLD', 1, 0)) AS REAL) * 100 / COUNT(T1.c_mktsegment) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'INDONESIA';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of all the products under the type "promo brushed steel". [/INST]
SELECT p_name FROM part WHERE p_type = 'PROMO BRUSHED STEEL';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the comment of the product "burlywood plum powder puff mint"? [/INST]
SELECT p_comment FROM part WHERE p_name = 'burlywood plum powder puff mint';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many parts have a retail price of over 1900? [/INST]
SELECT COUNT(p_partkey) FROM part WHERE p_retailprice > 1900;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the products under the type "promo brushed steel", how many of them are manufactured by Manufacturer#5? [/INST]
SELECT COUNT(p_partkey) FROM part WHERE p_type = 'PROMO BRUSHED STEEL' AND p_mfgr = 'Manufacturer#5';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list all the brands that contain a part under the type "promo brushed steel". [/INST]
SELECT p_brand FROM part WHERE p_type = 'PROMO BRUSHED STEEL';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the product with the highest retail price? [/INST]
SELECT p_name FROM part WHERE p_retailprice = ( SELECT MAX(p_retailprice) FROM part );
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which part has a bigger size, "pink powder drab lawn cyan" or "cornflower sky burlywood green beige"? [/INST]
SELECT T.p_name FROM ( SELECT p_name, p_size FROM part WHERE p_name IN ('pink powder drab lawn cyan', 'cornflower sky burlywood green beige') ) AS T ORDER BY p_size DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many parts have a jumbo case container? [/INST]
SELECT COUNT(p_partkey) FROM part WHERE p_container = 'JUMBO CASE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the size of the smallest part in a jumbo case container? [/INST]
SELECT MIN(p_size) FROM part WHERE p_container = 'JUMBO CASE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many suppliers have their accounts in debt? [/INST]
SELECT COUNT(s_suppkey) FROM supplier WHERE s_acctbal < 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of the top 3 suppliers with the most amount of money in their accounts. [/INST]
SELECT s_name FROM supplier ORDER BY s_acctbal DESC LIMIT 3;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the phone numbers of all the suppliers in Germany. [/INST]
SELECT T1.s_phone FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'Germany';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of all the suppliers for the part "hot spring dodger dim light". [/INST]
SELECT T2.s_name FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey WHERE T3.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the lowest supply cost for the part "hot spring dodger dim light"? [/INST]
SELECT MIN(T1.ps_supplycost) FROM partsupp AS T1 INNER JOIN part AS T2 ON T1.ps_partkey = T2.p_partkey WHERE T2.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the name of the supplier that provides the part "hot spring dodger dim light" with the lowest supply cost? [/INST]
SELECT T2.s_name FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey WHERE T3.p_name = 'hot spring dodger dim light' ORDER BY T1.ps_supplycost LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the total quantity available by all suppliers for the part "hot spring dodger dim light"? [/INST]
SELECT SUM(T1.ps_availqty) FROM partsupp AS T1 INNER JOIN part AS T2 ON T1.ps_partkey = T2.p_partkey WHERE T2.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which supplier can provide the most number of "hot spring dodger dim light"? Please give the supplier's phone number. [/INST]
SELECT T3.s_phone FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey WHERE T1.p_name = 'hot spring dodger dim light' ORDER BY T2.ps_availqty DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of all the suppliers for the part with the highest retail price. [/INST]
SELECT T3.s_phone FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey WHERE T1.p_name = 'hot spring dodger dim light' ORDER BY T1.p_size DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many suppliers for the part "hot spring dodger dim light" are in Vietnam? [/INST]
SELECT COUNT(T3.s_name) FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey INNER JOIN nation AS T4 ON T3.s_nationkey = T4.n_nationkey WHERE T1.p_name = 'hot spring dodger dim light' AND T4.n_name = 'VIETNAM';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the suppliers providing parts under the type "promo brushed steel", how many of them are in debt? [/INST]
SELECT COUNT(T3.s_name) FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey WHERE T3.s_acctbal < 0 AND T1.p_type = 'PROMO BRUSHED STEEL';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the names of all the suppliers for parts under Brand#55. [/INST]
SELECT T3.s_name FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey WHERE T1.p_brand = 'Brand#55';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among all the parts under the type "promo brushed steel", how many of them have a total available quantity from all suppliers of under 5000? [/INST]
SELECT SUM(num) FROM ( SELECT COUNT(T3.s_name) AS num FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN supplier AS T3 ON T2.ps_suppkey = T3.s_suppkey WHERE T1.p_type = 'PROMO BRUSHED STEEL' GROUP BY T2.ps_partkey HAVING SUM(T2.ps_availqty) < 5000 ) T;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: The part "hot spring dodger dim light" is ordered in how many orders? [/INST]
SELECT COUNT(T1.p_partkey) FROM part AS T1 INNER JOIN lineitem AS T2 ON T1.p_partkey = T2.l_partkey WHERE T1.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the total quantity of the part "hot spring dodger dim light" ordered in all orders? [/INST]
SELECT SUM(T1.p_partkey) FROM part AS T1 INNER JOIN lineitem AS T2 ON T1.p_partkey = T2.l_partkey WHERE T1.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the order keys of all the orders that have more than 2 parts with a jumbo case container. [/INST]
SELECT T.l_orderkey FROM ( SELECT T2.l_orderkey, COUNT(T2.l_partkey) AS num FROM part AS T1 INNER JOIN lineitem AS T2 ON T1.p_partkey = T2.l_partkey WHERE T1.p_container = 'JUMBO CASE' GROUP BY T2.l_orderkey ) AS T WHERE T.num > 2;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among all the suppliers in debt, how many of them are in Europe? [/INST]
SELECT COUNT(T1.n_nationkey) FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey INNER JOIN supplier AS T3 ON T1.n_nationkey = T3.s_nationkey WHERE T2.r_name = 'EUROPE' AND T3.s_acctbal < 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among all the suppliers providing the part "hot spring dodger dim light", how many of them are in Europe? [/INST]
SELECT COUNT(T1.r_regionkey) FROM region AS T1 INNER JOIN nation AS T2 ON T1.r_regionkey = T2.n_regionkey INNER JOIN supplier AS T3 ON T2.n_nationkey = T3.s_nationkey WHERE T1.r_name = 'EUROPE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list the phone numbers of all the suppliers for the parts ordered in order no.1. [/INST]
SELECT T2.s_phone FROM lineitem AS T1 INNER JOIN supplier AS T2 ON T1.l_suppkey = T2.s_suppkey WHERE T1.l_orderkey = 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the suppliers for the parts ordered in order no.4, how many of them are in debt? [/INST]
SELECT COUNT(T1.l_linenumber) FROM lineitem AS T1 INNER JOIN supplier AS T2 ON T1.l_suppkey = T2.s_suppkey WHERE T1.l_orderkey = 4 AND T2.s_acctbal < 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the parts that are returned, how many of them are provided by a supplier in debt? [/INST]
SELECT COUNT(T1.l_partkey) FROM lineitem AS T1 INNER JOIN supplier AS T2 ON T1.l_suppkey = T2.s_suppkey WHERE T1.l_returnflag = 'R' AND T2.s_acctbal < 0;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: On which date was the part "burnished seashell gainsboro navajo chocolate" in order no.1 shipped? [/INST]
SELECT T1.l_shipdate FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T1.l_orderkey = 1 AND T2.p_name = 'burnished seashell gainsboro navajo chocolate';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the quantity of the part "burnished seashell gainsboro navajo chocolate" ordered in order no.1? [/INST]
SELECT T1.l_quantity FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T1.l_orderkey = 1 AND T2.p_name = 'burnished seashell gainsboro navajo chocolate';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which part is ordered in a bigger amount in order no.1, "burnished seashell gainsboro navajo chocolate" or "salmon white grey tan navy"? [/INST]
SELECT T.p_name FROM ( SELECT T2.p_name, SUM(T1.l_quantity) AS num FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name IN ('salmon white grey tan navy', 'burnished seashell gainsboro navajo chocolate') GROUP BY T1.l_partkey ) AS T ORDER BY T.num DESC LIMIT 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the biggest discount among all orders for the part "burnished seashell gainsboro navajo chocolate"? [/INST]
SELECT MAX(T1.l_discount) FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name = 'burnished seashell gainsboro navajo chocolate';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Please list all the modes of shipping for the part "burnished seashell gainsboro navajo chocolate". [/INST]
SELECT DISTINCT T1.l_shipmode FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name = 'burnished seashell gainsboro navajo chocolate';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the average supply cost for the part "hot spring dodger dim light"? [/INST]
SELECT AVG(T1.ps_supplycost) FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey WHERE T3.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How much higher in percentage is the highest supply cost of the part "hot spring dodger dim light" than the lowest supply cost? [/INST]
SELECT CAST((MAX(T1.ps_supplycost) - MIN(T1.ps_supplycost)) AS REAL) * 100 / MIN(T1.ps_supplycost) FROM partsupp AS T1 INNER JOIN supplier AS T2 ON T1.ps_suppkey = T2.s_suppkey INNER JOIN part AS T3 ON T1.ps_partkey = T3.p_partkey WHERE T3.p_name = 'hot spring dodger dim light';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the profit for part no.98768 in order no.1? [/INST]
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_orderkey = 1 AND T1.l_partkey = 98768;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: What is the discounted price of the part "burnished seashell gainsboro navajo chocolate" in order no.1? [/INST]
SELECT T1.l_extendedprice * (1 - T1.l_discount) FROM lineitem AS T1 INNER JOIN part AS T2 ON T1.l_partkey = T2.p_partkey WHERE T2.p_name = 'burnished seashell gainsboro navajo chocolate' AND T1.l_orderkey = 1;
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Which market segment does the customer with the highest amount of debt belongs to? [/INST]
SELECT c_mktsegment FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer );
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: In 1997, how many orders were shipped via mail? [/INST]
SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%Y', l_shipdate) = '1997' AND l_shipmode = 'MAIL';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: How many customers are in the furniture segment? [/INST]
SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'FURNITURE';
[INST] Here is a database schema: customer : c_custkey [ INTEGER ] primary_key c_mktsegment [ TEXT ] c_nationkey [ INTEGER ] customer.c_nationkey = nation.n_nationkey c_name [ TEXT ] c_address [ TEXT ] c_phone [ TEXT ] c_acctbal [ REAL ] c_comment [ TEXT ] lineitem : l_shipdate [ DATE ] l_orderkey [ INTEGER ] lineitem.l_orderkey = orders.o_orderkey l_discount [ REAL ] l_extendedprice [ REAL ] l_suppkey [ INTEGER ] lineitem.l_suppkey = partsupp.ps_suppkey l_quantity [ INTEGER ] l_returnflag [ TEXT ] l_partkey [ INTEGER ] lineitem.l_partkey = partsupp.ps_partkey l_linestatus [ TEXT ] l_tax [ REAL ] l_commitdate [ DATE ] l_receiptdate [ DATE ] l_shipmode [ TEXT ] l_linenumber [ INTEGER ] l_shipinstruct [ TEXT ] l_comment [ TEXT ] nation : n_nationkey [ INTEGER ] primary_key n_name [ TEXT ] n_regionkey [ INTEGER ] nation.n_regionkey = region.r_regionkey n_comment [ TEXT ] orders : o_orderdate [ DATE ] o_orderkey [ INTEGER ] primary_key o_custkey [ INTEGER ] orders.o_custkey = customer.c_custkey o_orderpriority [ TEXT ] o_shippriority [ INTEGER ] o_clerk [ TEXT ] o_orderstatus [ TEXT ] o_totalprice [ REAL ] o_comment [ TEXT ] part : p_partkey [ INTEGER ] primary_key p_type [ TEXT ] p_size [ INTEGER ] p_brand [ TEXT ] p_name [ TEXT ] p_container [ TEXT ] p_mfgr [ TEXT ] p_retailprice [ REAL ] p_comment [ TEXT ] partsupp : ps_partkey [ INTEGER ] partsupp.ps_partkey = part.p_partkey ps_suppkey [ INTEGER ] partsupp.ps_suppkey = supplier.s_suppkey ps_supplycost [ REAL ] ps_availqty [ INTEGER ] ps_comment [ TEXT ] region : r_regionkey [ INTEGER ] primary_key r_name [ TEXT ] r_comment [ TEXT ] supplier : s_suppkey [ INTEGER ] primary_key s_nationkey [ INTEGER ] supplier.s_nationkey = nation.n_nationkey s_comment [ TEXT ] s_name [ TEXT ] s_address [ TEXT ] s_phone [ TEXT ] s_acctbal [ REAL ] Please write me a SQL statement that answers the following question: Among the items shipped in 1994 via truck, how many items were returned? [/INST]
SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%Y', l_shipdate) = '1994' AND l_returnflag = 'R' AND l_shipmode = 'TRUCK';