db_id stringclasses 68 values | question stringlengths 24 325 | evidence stringlengths 0 580 | SQL stringlengths 23 728 |
|---|---|---|---|
retails | Which country has the most number of suppliers whose account is in debt? | country refers to n_name; the most number of suppliers whose account is in debt refers to MAX(SUM(s_acctbal < 0)); | SELECT T.n_name FROM ( SELECT T2.n_name, SUM(T1.s_acctbal) AS num FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T1.s_acctbal < 0 GROUP BY T2.n_name ) AS T ORDER BY T.num LIMIT 1 |
retails | What is the name of the customer with the highest amount of debt? | customer with the highest amount of debt refers to c_name where MIN(c_acctbal); | SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer ) |
retails | How many customers are in debt? | customers are in debt refer to c_custkey where c_acctbal < 0; | SELECT COUNT(c_custkey) FROM customer WHERE c_acctbal < 0 |
retails | How many customers are in the automobile market segment? | automobile market segment refers to c_mktsegment = 'AUTOMOBILE'; | SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'AUTOMOBILE' |
retails | What are the top 2 order keys of the item with the highest amount of extended price? | the highest amount of extended price refers to MAX(l_extendedprice); | SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice DESC LIMIT 2 |
retails | When was the order with the highest amount of total price shipped? | when shipped refers to l_shipdate; the highest amount of total price refers to MAX(o_totalprice); | SELECT T2.l_shipdate FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey ORDER BY T1.o_totalprice DESC LIMIT 1 |
retails | In which country do most of the customers come from? | country refers to n_name; most of the customers refer to MAX(COUNT(c_custkey)); | SELECT T.n_name FROM ( SELECT T2.n_name, COUNT(T1.c_custkey) AS num FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey GROUP BY T2.n_name ) AS T ORDER BY T.num DESC LIMIT 1 |
retails | How many in debt customers in the household market segment are from Russia? | in debt customers refer to c_custkey where c_acctbal < 0; c_mktsegment = 'HOUSEHOLD'; Russian is the name of the nation which refers to n_name = 'RUSSIA'; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal < 0 AND T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'RUSSIA' |
retails | How many suppliers are from Japan? | suppliers refer to s_nationkey; Japan is the name of the nation which refers to n_name = 'JAPAN'; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'JAPAN' |
retails | How many orders shipped via ship have a medium priority? | orders shipped via ship refer to o_orderkey where l_shipmode = 'SHIP'; medium priority refers to o_orderpriority = '3-MEDIUM'; | SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'SHIP' AND T1.o_orderpriority = '3-MEDIUM' |
retails | Among the customers from the United States, which market segment has the highest number of customers? | the highest number of customers refer to MAX(COUNT(c_custkey)); the United States is the name of the nation which refers to n_name = 'UNITED STATES'; market segment refers to c_mktsegment; | SELECT T.c_mktsegment FROM ( SELECT T1.c_mktsegment, COUNT(T1.c_custkey) AS num FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'UNITED STATES' GROUP BY T1.c_mktsegment ) AS T ORDER BY T.num DESC LIMIT 1 |
retails | What are the countries in the region of Asia? | countries in the region of Asia refer to n_name where r_name = 'ASIA'; | SELECT T1.n_name FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_name = 'ASIA' |
retails | What are the names of the parts manufactured by manufacturer 3 that have a supply cost of 1,000? | names of the parts refer to p_name; manufacturer 3 refers to p_mfgr = 'Manufacturer#3'; ps_supplycost = 1000; | SELECT T2.p_name FROM partsupp AS T1 INNER JOIN part AS T2 ON T1.ps_partkey = T2.p_partkey WHERE T1.ps_supplycost = 1000 AND T2.p_mfgr = 'Manufacturer#3' |
retails | How many countries are there in the region whose comment description is "asymptotes sublate after the r." | r_comment = 'asymptotes sublate after the r'; countries refer to n_nationkey; | SELECT COUNT(T1.n_nationkey) FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_comment = 'asymptotes sublate after the r' |
retails | Among the products manufactured by manufacturer 5 that have a retail price of no more than 1,000, how many products were shipped via rail? | manufacturer 5 refers to p_mfgr = 'Manufacturer#5'; retail price of no more than 1,000 refers to p_retailprice < 1000; shipped via rail refers to shipmode = 'RAIL'; | SELECT COUNT(T1.ps_partkey) 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 WHERE T3.p_mfgr = 'Manufacturer#5' AND T3.p_retailprice < 1000 AND T2.l_shipmode = 'RAIL' |
retails | How much is the profit for smoke turquoise purple blue salmon that was delivered in person on 5/7/1996? | SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) where p_name = 'smoke turquoise purple blue salmon' and l_receiptdate = '1996-05-07' and l_shipinstruct = 'DELIVER IN PERSON'; | SELECT T1.l_extendedprice * (1 - T1.l_discount) - T2.ps_supplycost * T1.l_quantity AS num FROM lineitem AS T1 INNER JOIN partsupp AS T2 ON T1.l_suppkey = T2.ps_suppkey INNER JOIN part AS T3 ON T2.ps_partkey = T3.p_partkey WHERE T1.l_receiptdate = '1996-05-07' AND T1.l_shipinstruct = 'DELIVER IN PERSON' AND T3.p_name = 'smoke turquoise purple blue salmon' |
retails | How many items were shipped on 4th December, 1993? | items shipped on 4th December, 1993 refer to l_linenumber where l_shipdate = '1993-12-04'; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipdate = '1993-12-04' |
retails | What was the order date of items with the highest total price? | the highest total price refers to MAX(o_totalprice); | SELECT o_orderdate FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders ) |
retails | How many part supplies were nearly out of stock? | supplies nearly out of stock refer to ps_partkey where ps_availqty < 10; | SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10 |
retails | List any five parts name in Medium Plated Brass. | p_type = 'MEDIUM PLATED BRASS'; parts name refer to p_name; | SELECT p_name FROM part WHERE p_type = 'MEDIUM PLATED BRASS' LIMIT 5 |
retails | How many customers are there in India? | customers refer to c_custkey; India is the name of the nation which refers to n_name = 'INDIA'; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'INDIA' |
retails | Among the customers from Morocco, how many customers were in debt? | customers refer to c_custkey; Morocco is the name of the nation which refers to n_name = 'MOROCCO'; in debt refers to c_acctbal < 0; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal < 0 AND T2.n_name = 'MOROCCO' |
retails | List down the nation keys and names in Africa. | Africa refers to r_name = 'Africa'; | SELECT T1.n_name, T1.n_nationkey FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_name = 'AFRICA' |
retails | Calculate the total price of orders by Customer#000000013. | Customer#000000013 is the name of the customer which refers to c_name; | SELECT SUM(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_name = 'Customer#000000013' |
retails | Calculate the total profit made by chocolate floral blue coral cyan. | SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) where p_name = 'chocolate floral blue coral cyan'; | SELECT SUM(T3.l_extendedprice * (1 - T3.l_discount) - T2.ps_supplycost * T3.l_quantity) FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN lineitem AS T3 ON T2.ps_partkey = T3.l_partkey AND T2.ps_suppkey = T3.l_suppkey WHERE T1.p_name = 'chocolate floral blue coral cyan' |
retails | List the suppliers' names which supplied smoke red pale saddle plum. | p_name = 'smoke red pale saddle plum'; the suppliers' names refer to s_name; | 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_name = 'smoke red pale saddle plum' |
retails | Among the suppliers from Middle East region, how many suppliers were in debt? | suppliers from Middle East region refer to s_name where r_name = 'MIDDLE EAST'; in debt refers to s_acctbal < 0; | SELECT COUNT(T3.s_name) 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 T3.s_acctbal < 0 AND T1.r_name = 'MIDDLE EAST' |
retails | Among the parts supplied by Supplier#000000018, provide parts names which had supply costs above 900. | Supplier#000000018 is the name of supplier which refers to s_name; supply costs above 900 refer to ps_supplycost > 900; | SELECT T2.p_name FROM partsupp AS T1 INNER JOIN part AS T2 ON T1.ps_partkey = T2.p_partkey INNER JOIN supplier AS T3 ON T1.ps_suppkey = T3.s_suppkey WHERE T1.ps_supplycost > 900 AND T3.s_name = 'Supplier#000000018' |
retails | How many of the line items have been shipped by rail with a quantity less than 30? | shipped by rail refers to l_shipmode = 'RAIL'; quantity less than 30 refers to l_quantity < 30; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity < 30 AND l_shipmode = 'RAIL' |
retails | Among the customers in the furniture market segment, how many of them have a nation key of 1? | furniture market segment refers to c_mktsegment = 'FURNITURE'; | SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'FURNITURE' AND c_nationkey = 1 |
retails | Give the phone number of the customer with the highest account balance. | phone number of the customer refers to c_phone; the highest account balance refers to MAX(c_acctbal); | SELECT c_phone FROM customer ORDER BY c_acctbal DESC LIMIT 1 |
retails | What is the order priority of the order with the highest total price? | order with the highest total price refers to MAX(o_totalprice); | SELECT o_orderpriority FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders ) |
retails | What is the total number of orders made by customers in United States? | orders refer to o_orderkey; the United States is the name of the nation which refers to n_name = 'UNITED STATES'; | SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey INNER JOIN nation AS T3 ON T2.c_nationkey = T3.n_nationkey WHERE T3.n_name = 'UNITED STATES' |
retails | Among the customers from Brazil, how many customers are in automobile market segment? | customers refer to c_custkey; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; c_mktsegment = 'automobile'; | 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 = 'AUTOMOBILE' AND T2.n_name = 'BRAZIL' |
retails | List down the countries that are located in Asia. | countries in Asia refer to n_name where r_name = 'ASIA'; | SELECT T1.n_name FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_name = 'ASIA' |
retails | Name the countries that belong in the region with comment description "furiously express accounts wake sly". | r_comment = 'furiously express accounts wake sly'; | SELECT T1.n_name FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey WHERE T2.r_comment = 'furiously express accounts wake sly' |
retails | What is the total number of suppliers from Germany? | suppliers refer to s_suppkey; Germany is the name of the nation which refers to n_name = 'GERMANY'; | SELECT COUNT(T1.s_suppkey) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'GERMANY' |
retails | Among the customers in Asia, how many customers are in debt? | customers in Asia refer to n_name where r_name = 'ASIA'; customers in debt refer to c_acctbal < 0; | SELECT COUNT(T1.n_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_acctbal < 0 AND T3.r_name = 'ASIA' |
retails | Provide the phone number of the customer with the highest total price in an order. | phone number of the customer refers to c_phone; the highest total price refers to MAX(o_totalprice); | SELECT T2.c_phone FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey ORDER BY T1.o_totalprice DESC LIMIT 1 |
retails | Among the products that have a retail price greater than 1,000, how many products were shipped via ship? | products refer to l_partkey; retail price greater than 1,000 refers to p_retailprice > 1000; shipped via ship refers to l_shipmode = 'SHIP'; | SELECT COUNT(T1.ps_suppkey) 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 WHERE T3.p_retailprice > 1000 AND T2.l_shipmode = 'SHIP' |
retails | Provide the nation and region of the customer with the address of wH55UnX7 VI? | nation refers to n_name; region refers to r_name; address of wH55UnX7 VI refers to c_address = 'wH55UnX7 VI'; | 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_address = 'wH55UnX7 VI' |
retails | Among all the customers in Brazil, how many of them have an account balance of less than 1000? | customers refer to c_custkey; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; account balance of less than 1000 refers to c_acctbal < 1000; | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T2.n_name = 'BRAZIL' AND T1.c_acctbal < 1000 |
retails | Give the name and phone number of the customers who have more than 9000 account balance. | the name of the customer refers to c_name; phone number of the customer refers to c_phone; have more than 9000 account balance refers to c_acctbal > 9000; | SELECT c_name, c_phone FROM customer WHERE c_acctbal > 9000 |
retails | What is the average number of items shipped each day in April of 1994? | AVG(l_linenumber) where l_shipdate between '1994-01-01' and '1994-01-30'; | SELECT AVG(l_linenumber) FROM lineitem WHERE l_shipdate BETWEEN '1994-01-01' AND '1994-01-30' |
retails | List the order key of the orders with a total price between 200000 and 300000. | orders with a total price between 200000 and 300000 refer to o_totalprice between 200000 and 300000; | SELECT o_orderkey FROM orders WHERE o_totalprice BETWEEN 200000 AND 300000 |
retails | Find and list the part key of the parts which has an above-average retail price. | part key of the parts which has an above-average retail price refer to p_partkey where p_retailprice > AVG(p_retailprice); | SELECT p_partkey FROM part WHERE p_retailprice > ( SELECT AVG(p_retailprice) FROM part ) |
retails | Find the supply key of the top ten suppliers with the most account balance, and list the supply key along with the account balance in descending order of account balance. | supply key refers to s_suppkey; the most amount account balance refers to MAX(s_acctbal); | SELECT s_suppkey, s_acctbal FROM supplier ORDER BY s_acctbal DESC LIMIT 10 |
retails | How many customers who are not in debt ordered an urgent order? | customers who are not in debt refer to c_custkey where c_acctbal > 0; the order is urgent if o_orderpriority = '1-URGENT' ; | SELECT COUNT(T2.c_custkey) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_acctbal > 0 AND T1.o_orderpriority = '1-URGENT' |
retails | List the name and phone number of customers in India who have an above-average account balance. | name of customer refers to c_name; phone number of customer refers to c_phone; customers in India who have an above-average account balance refer to n_name = 'INDIA' and c_acctbal > AVG(c_acctbal); | SELECT T1.c_name, T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_acctbal > ( SELECT AVG(c_acctbal) FROM customer ) ORDER BY T1.c_name |
retails | In the parts supply by Supplier#000000654, list the top five parts with the most supply cost in descending order of supply cost. | Supplier#000000654 is the name of the supplier which refers to s_name; parts with the most supply cost refer to ps_partkey where MAX(ps_supplycost); | SELECT T2.ps_partkey FROM supplier AS T1 INNER JOIN partsupp AS T2 ON T1.s_suppkey = T2.ps_suppkey WHERE T1.s_name = 'Supplier#000000654' ORDER BY T2.ps_supplycost DESC LIMIT 5 |
retails | Name the part which is most profitable. | profit can be calculated as SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))); part which is most profitable refers to p_name where MAX(profit); | SELECT T.p_name FROM ( SELECT T3.p_name , T2.l_extendedprice * (1 - T2.l_discount) - T1.ps_supplycost * T2.l_quantity AS num 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 ) AS T ORDER BY T.num DESC LIMIT 1 |
retails | List the names of the countries with the below-average number of customers in ascending order of customer numbers. | the names of countries with the below-average number of customers refer to n_name where COUNT(c_name) < DIVIDE(COUNT(c_name)), COUNT(n_name); | SELECT T2.n_name FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey GROUP BY T2.n_name HAVING COUNT(T1.c_name) > ( SELECT COUNT(customer.c_name) / COUNT(DISTINCT nation.n_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey ) ORDER BY COUNT(T1.c_name) |
retails | List the name of the top ten items with the most quantity available in the descending order of availability. | items with the most quantity available refer to p_name where MAX(ps_availqty); | SELECT T1.p_name FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey ORDER BY T2.ps_availqty DESC LIMIT 10 |
retails | What is the average discount for the parts made by Manufacturer#5? | DIVIDE(SUM(l_discount), COUNT(l_partkey)) where p_mfgr = 'Manufacturer#5'; | SELECT AVG(T3.l_discount) FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey INNER JOIN lineitem AS T3 ON T2.ps_suppkey = T3.l_suppkey WHERE T1.p_mfgr = 'Manufacturer#5' |
retails | In the parts shipped by rail, how many are of medium priority? | parts shipped by rail refer to l_partkey where l_shipmode = 'RAIL'; medium priority refers to o_orderpriority = '3-MEDIUM'; | SELECT COUNT(T2.l_partkey) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'RAIL' AND T1.o_orderpriority = '3-MEDIUM' |
retails | List by their id all customers who have a debit balance in their accounts. | customers who have a debt balance refer to c_custkey where c_acctbal < 0; | SELECT c_custkey FROM customer WHERE c_acctbal < 0 |
retails | List by order number the 3 items with the lowest price after applying the discount. | order number refers to l_orderkey; the lowest price after applying the discount refers to MIN(MULTIPLY(l_extendedprice), SUBTRACT(1, l_discount)); | SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice * (1 - l_discount) LIMIT 3 |
retails | How many orders of more than 10 items have been returned? | more than 10 items have been returned refer to l_returnflag = 'R' where l_quantity > 10; orders refer to l_orderkey; | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 10 AND l_returnflag = 'R' |
retails | What is the total price charged for orders shipped by air without shipping instructions? | SUM(MULTIPLY(MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)), SUM(1, l_tax))) where l_shipmode = 'AIR' and l_shipinstruct = 'NONE'; | SELECT l_extendedprice * (1 - l_discount) * (1 + l_tax) AS totalprice FROM lineitem WHERE l_shipmode = 'AIR' AND l_shipinstruct = 'NONE' |
retails | Of the orders with a lower delivery priority, how many have an urgent priority order? | an urgent priority order refers to o_orderkey where o_orderpriority = '1-URGENT'; earlier orderdate have higher priority in delivery; lower delivery priority refers to MAX(o_orderdate); | SELECT COUNT(o_orderkey) FROM orders WHERE o_orderpriority = '1-URGENT' GROUP BY o_orderdate ORDER BY o_orderdate DESC LIMIT 1 |
retails | How many suppliers from Egypt have a debit balance? | suppliers refer to s_suppkey; Egypt is the name of the nation which refers to n_name = 'EGYPT'; the balance is in debt if s_acctbal < 0; | 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 = 'EGYPT' |
retails | How many items shipped by REG AIR were ordered on March 22, 1995? | items shipped by REG AIR refer to l_linenumber where l_shipmode = 'REG AIR'; ordered on March 22, 1995 refers to o_orderdate = '1995-03-22'; | SELECT COUNT(T1.o_orderkey) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T2.l_shipmode = 'REG AIR' AND T1.o_orderdate = '1995-03-22' |
retails | How many European suppliers are there? | European suppliers refer to s_suppkey where r_name = 'EUROPE'; | 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' |
retails | Lists all parts supplied by Supplier#000000034. | part refers to p_name; Supplier#000000034 refers to s_name = 'Supplier#000000034' | SELECT T3.p_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 T2.s_name = 'Supplier#000000034' |
retails | What are the cost prices of large burnished copper? | cost price refers to ps_supplycost; large burnished copper refers to p_type = 'LARGE BURNISHED COPPER' | 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 BURNISHED COPPER' |
retails | How many clients from Mozambique required orders with a low priority order? | Mozambique refers to n_name = 'MOZAMBIQUE'; low priority order refers to o_orderpriority = '5-LOW' | SELECT COUNT(T1.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey INNER JOIN orders AS T3 ON T1.c_custkey = T3.o_custkey WHERE T2.n_name = 'MOZAMBIQUE' AND T3.o_orderpriority = '5-LOW' |
retails | Indicate the name of the product that is close to being sold out and that has the lowest cost price. | name of the product refers to p_name; close to being sold out refers to ps_availqty < 10; the lowest cost price refers to min(ps_supplycost) | SELECT T1.p_name FROM part AS T1 INNER JOIN partsupp AS T2 ON T1.p_partkey = T2.ps_partkey WHERE T2.ps_availqty < 10 ORDER BY T2.ps_supplycost LIMIT 1 |
retails | How many different clerks have served the customer with the address uFTe2u518et8Q8UC? | clerk who have served the customer refers to o_clerk
| SELECT COUNT(T1.o_clerk) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_address = 'uFTe2u518et8Q8UC' |
retails | Indicate the name of the parts without discount. | name of the part refers to p_name; without discount refers to l_discount = 0.0000 | SELECT T3.p_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 WHERE T2.l_discount = 0.0000 |
retails | How many suppliers from Germany have left a comment with 'carefully regular packages'? | Germany is nation name which refers to n_name = 'GERMANY'; comment with 'carefully regular packages' refers to s_comment LIKE 'carefully regular packages%' | SELECT COUNT(T1.s_suppkey) FROM supplier AS T1 INNER JOIN nation AS T2 ON T1.s_nationkey = T2.n_nationkey WHERE T2.n_name = 'GERMANY' AND T1.s_comment LIKE '%carefully regular packages%' |
retails | How many products shipped on 19/11/1994 were ordered on 21/09/1994? | shipped on 19/11/1994 refers to l_shipdate = '1994-11-19'; ordered on 21/09/1994 refers to o_orderdate = '1994-09-21' | SELECT COUNT(T2.l_partkey) FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey WHERE T1.o_orderdate = '1994-09-21' AND T2.l_shipdate = '1994-11-19' |
retails | Calculate the average profit of prom brushed steel products. | prom brushed steel refers to p_type = 'PROMO BRUSHED STEEL'; average profit = divide(sum(subtract(multiply(l_extendedprice, subtract(1, l_discount)), multiply(ps_supplycost, l_quantity))), count(ps_partkey)) | SELECT SUM(T2.l_extendedprice * (1 - T2.l_discount) - T1.ps_supplycost * T2.l_quantity) / COUNT(T1.ps_partkey) 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 WHERE T3.p_type = 'PROMO BRUSHED STEEL' |
retails | Please state the segment, the name, the address, and the phone number of customer number 3. | segment refers to c_mktsegment; name refers to c_name; address refers to c_address; phone number refers to c_phone; customer number 3 refers to c_custkey = 3 | SELECT c_mktsegment, c_name, c_address, c_phone FROM customer WHERE c_custkey = 3 |
retails | How many of the line items that have a quantity greater than 40 have been shipped by air? | quantity greater than 40 refers to l_quantity > 40; shipped by air refers to l_shipmode = 'AIR' | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 40 AND l_shipmode = 'AIR' |
retails | What is the total price and the order priority of order number 33? | total price refers to o_totalprice; order priority refers to o_orderpriority; order number 33 refers to o_orderkey = 33 | SELECT o_totalprice, o_orderpriority FROM orders WHERE o_orderkey = 33 |
retails | Please list any three customers with debt. | customer refers to c_name; with debt refers to c_acctbal < 0 | SELECT c_name FROM customer WHERE c_acctbal < 0 LIMIT 3 |
retails | What is the discounted price of line item number 1? | discounted price refers to multiply(l_extendedprice, subtract(1, l_discount)); line item number 1 refers to l_linenumber = 1 | SELECT l_extendedprice * (1 - l_discount) FROM lineitem WHERE l_linenumber = 1 |
retails | Please name any three parts that have an available quantity of more than 9998. | part name refers to p_name; an available quantity of more than 9998 refers to ps_availqty > 9998 | 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 |
retails | Please list any two parts that come with the wrap bag container and have a supply cost of under 10. | part name refers to p_name; wrap bag container refers to p_container = 'WRAP BAG'; supply cost of under 10 refers to ps_supplycost < 10 | 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 |
retails | What is the nationality of supplier number 1? | nationality refers to n_name; supplier number 1 refers to s_suppkey = 1 | 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 |
retails | Which region has the lowest number of countries? | region refers to has r_name; the lowest number of countries refers to min(count(n_name)) | 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 |
retails | How many customers from the furniture segments come from Iraq? | furniture segment refers to c_mktsegment = 'FURNITURE'; Iraq refers to n_name = 'Iraq' | 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' |
retails | Which nation and region does the Customer#000000008 come from? | nation refers to n_name; region refers to r_name; Customer#000000008 refers to c_name = 'Customer#000000008' | 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' |
retails | How many Japanese suppliers have their accounts in debt? | Japanese refers to n_name = 'Japan'; have accounts in debt refers to s_acctbal < 0 | 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' |
retails | Which customer is the most in debt? | customer refers to c_name; the most in debt refers to max(c_acctbal) | SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer ) |
retails | List all the dates of the urgent orders. | date refers to o_orderdate; urgent order refers to o_orderpriority = '1-URGENT' | SELECT o_orderdate FROM orders WHERE o_orderpriority = '1-URGENT' |
retails | How many of the items are instructed to be delivered in person? | instructed to be delivered in person refers to l_shipinstruct = 'DELIVER IN PERSON' | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipinstruct = 'DELIVER IN PERSON' |
retails | What is the largest supplier's account balance? | the largest supplier's account balance refers to max(s_acctbal) | SELECT MAX(s_acctbal) FROM supplier |
retails | How many part supplies are close to being out of stock? | close to being out of stock refers to ps_availqty < 10 | SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10 |
retails | List all the nations in Europe. | nation refers to n_name; Europe refers to r_name = 'EUROPE' | 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' |
retails | What is the supply cost for the part "violet olive rose ivory sandy"? | supply cost refers to ps_supplycost; part "violet olive rose ivory sandy" refers to p_name = 'violet olive rose ivory sandy' | 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' |
retails | What is the total price of all orders from the customer with the phone number "627-220-3983"? | total price = sum(o_totalprice); phone number "627-220-3983" refers to c_phone = '627-220-3983' | 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' |
retails | What are the shipping methods for the orders on 12/31/1994? | shipping method refers to l_shipmode; order on 12/31/1994 refers to o_orderdate = '1994-12-31' | 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' |
retails | What is the account balance of the supplier with the most parts? | account balance refers to s_acctbal; the most parts refers to max(count(ps_suppkey)) | 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 |
retails | What is the region with the most customers? | region refers to r_name; the most customers refers to max(count(c_custkey)) | 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 |
retails | List the phone number of the customer who placed orders with a total price of more than $300,000. | phone number refers to c_phone; a total price of more than $300,000 refers to o_totalprice > 300000 | 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 |
retails | What are the clerks of orders with line items shipped by mail? | clerk refers to o_clerk; shipped by mail refers to l_shipmode = 'MAIL' | 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' |
retails | What are the top 5 nations of suppliers with the lowest account balance? | nation refers to n_name; the lowest account balance refers to min(s_acctbal) | 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 |
retails | List all the addresses for the suppliers of the biggest parts. | addresses refers to s_address; the biggest part refers to max(p_size) | 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 |
retails | Which part and supplier have the most profit? | part refers to p_name; supplier refers to s_name; the most profit refers to max(subtract(multiply(l_extendedprice, subtract(1, l_discount)), multiply(ps_supplycost, l_quantity))) | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.