Chinastark/bird_dataset huggingface dataset:
Database: retails
Note: SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) WHERE l_suppkey = 7414 AND l_orderkey = 817154;
Question: Calculates the profit processed by Supplier No. 7414 on order No. 817154.
SQL: SELECT lineitem.l_extendedprice * (1 - lineitem.l_discount) - partsupp.ps_supplycost * lineitem.l_quantity FROM lineitem INNER JOIN partsupp ON lineitem.l_suppkey = partsupp.ps_suppkey WHERE lineitem.l_suppkey = 7414 AND lineitem.l_orderkey = 817154
Database: retails
Note: country refers to n_name; the most number of suppliers whose account is in debt refers to MAX(SUM(s_acctbal < 0));
Question: Which country has the most number of suppliers whose account is in debt?
SQL: SELECT t.n_name FROM ( SELECT nation.n_name, sum(supplier.s_acctbal) AS num FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_acctbal < 0 GROUP BY nation.n_name ) AS t ORDER BY t.num LIMIT 1
Database: retails
Note: DIVIDE(COUNT(n_name where r_name = 'EUROPE'), COUNT(n_name)) as percentage;
Question: What is the percentage of the European countries among the given countries?
SQL: SELECT cast(sum(iif(region.r_name = 'EUROPE', 1, 0)) AS REAL) * 100 / count(nation.n_name) FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey
Database: retails
Note: account is in debt if s_acctbal < 0; DIVIDE(COUNT(s_acctbal < 0 where n_name = 'JAPAN'), COUNT(s_name where n_name = 'JAPAN')) as percentage;
Question: Give the percentage of Japanese suppliers whose account is in debt.
SQL: SELECT cast(sum(iif(nation.n_name = 'JAPAN', 1, 0)) AS REAL) * 100 / count(supplier.s_name) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_acctbal < 0
Database: retails
Note: customer with the highest amount of debt refers to c_name where MIN(c_acctbal);
Question: What is the name of the customer with the highest amount of debt?
SQL: SELECT c_name FROM customer WHERE c_acctbal = ( SELECT min(c_acctbal) FROM customer )
Database: retails
Note: orders refer to l_orderkey; shipped in 1998 refers to year(l_shipdate) = 1998;
Question: How many orders were shipped in 1998?
SQL: SELECT count(l_orderkey) FROM lineitem WHERE strftime('%Y', l_shipdate) = '1998'
Database: retails
Note: customers are in debt refer to c_custkey where c_acctbal < 0;
Question: How many customers are in debt?
SQL: SELECT count(c_custkey) FROM customer WHERE c_acctbal < 0
Database: retails
Note: items refer to l_linenumber; shipped via air in 1994 refers to year(l_shipdate) = 1994 where l_shipmode = 'AIR'; returned refer to l_returnflag = 'R';
Question: How many items that were shipped via air were returned in 1994?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_returnflag = 'R' AND l_shipmode = 'AIR' AND strftime('%Y', l_shipdate) = '1994'
Database: retails
Note: automobile market segment refers to c_mktsegment = 'AUTOMOBILE';
Question: How many customers are in the automobile market segment?
SQL: SELECT count(c_custkey) FROM customer WHERE c_mktsegment = 'AUTOMOBILE'
Database: retails
Note: the highest amount of extended price refers to MAX(l_extendedprice);
Question: What are the top 2 order keys of the item with the highest amount of extended price?
SQL: SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice DESC LIMIT 2
Database: retails
Note: when shipped refers to l_shipdate; the highest amount of total price refers to MAX(o_totalprice);
Question: When was the order with the highest amount of total price shipped?
SQL: SELECT lineitem.l_shipdate FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey ORDER BY orders.o_totalprice DESC LIMIT 1
Database: retails
Note: country refers to n_name; most of the customers refer to MAX(COUNT(c_custkey));
Question: In which country do most of the customers come from?
SQL: SELECT t.n_name FROM ( SELECT nation.n_name, count(customer.c_custkey) AS num FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey GROUP BY nation.n_name ) AS t ORDER BY t.num DESC LIMIT 1
Database: retails
Note: the order is urgent if o_orderpriority = '1-URGENT'; shipped the next day refers to SUBTRACT(l_shipdate, o_orderdate) = 1;
Question: How many urgent orders were shipped the next day?
SQL: SELECT count(orders.o_orderkey) FROM lineitem INNER JOIN orders ON orders.o_orderkey = lineitem.l_orderkey WHERE julianday(lineitem.l_shipdate) - julianday(orders.o_orderdate) = 1 AND orders.o_orderpriority = '1-URGENT'
Database: retails
Note: 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';
Question: How many in debt customers in the household market segment are from Russia?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_acctbal < 0 AND customer.c_mktsegment = 'HOUSEHOLD' AND nation.n_name = 'RUSSIA'
Database: retails
Note: suppliers refer to s_nationkey; Japan is the name of the nation which refers to n_name = 'JAPAN';
Question: How many suppliers are from Japan?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'JAPAN'
Database: retails
Note: orders shipped via ship refer to o_orderkey where l_shipmode = 'SHIP'; medium priority refers to o_orderpriority = '3-MEDIUM';
Question: How many orders shipped via ship have a medium priority?
SQL: SELECT count(orders.o_orderkey) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE lineitem.l_shipmode = 'SHIP' AND orders.o_orderpriority = '3-MEDIUM'
Database: retails
Note: 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;
Question: Among the customers from the United States, which market segment has the highest number of customers?
SQL: SELECT t.c_mktsegment FROM ( SELECT customer.c_mktsegment, count(customer.c_custkey) AS num FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'UNITED STATES' GROUP BY customer.c_mktsegment ) AS t ORDER BY t.num DESC LIMIT 1
Database: retails
Note: countries in the region of Asia refer to n_name where r_name = 'ASIA';
Question: What are the countries in the region of Asia?
SQL: SELECT nation.n_name FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE region.r_name = 'ASIA'
Database: retails
Note: names of the parts refer to p_name; manufacturer 3 refers to p_mfgr = 'Manufacturer#3'; ps_supplycost = 1000;
Question: What are the names of the parts manufactured by manufacturer 3 that have a supply cost of 1,000?
SQL: SELECT part.p_name FROM partsupp INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE partsupp.ps_supplycost = 1000 AND part.p_mfgr = 'Manufacturer#3'
Database: retails
Note: r_comment = 'asymptotes sublate after the r'; countries refer to n_nationkey;
Question: How many countries are there in the region whose comment description is "asymptotes sublate after the r."
SQL: SELECT count(nation.n_nationkey) FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE region.r_comment = 'asymptotes sublate after the r'
Database: retails
Note: 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';
Question: 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?
SQL: SELECT count(partsupp.ps_partkey) FROM partsupp INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE part.p_mfgr = 'Manufacturer#5' AND part.p_retailprice < 1000 AND lineitem.l_shipmode = 'RAIL'
Database: retails
Note: 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';
Question: How much is the profit for smoke turquoise purple blue salmon that was delivered in person on 5/7/1996?
SQL: SELECT lineitem.l_extendedprice * (1 - lineitem.l_discount) - partsupp.ps_supplycost * lineitem.l_quantity AS num FROM lineitem INNER JOIN partsupp ON lineitem.l_suppkey = partsupp.ps_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE lineitem.l_receiptdate = '1996-05-07' AND lineitem.l_shipinstruct = 'DELIVER IN PERSON' AND part.p_name = 'smoke turquoise purple blue salmon'
Database: retails
Note: DIVIDE(SUM(l_extendedprice), 10) where MAX(o_totalprice);
Question: What is the average price before discount of the top 10 orders with the highest total price?
SQL: SELECT sum(lineitem.l_extendedprice) / 10 FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey ORDER BY orders.o_totalprice DESC LIMIT 10
Database: retails
Note: customers with the highest number of orders refer to c_name where MAX(COUNT(o_orderkey)); DIVIDE(SUM(o_totalprice), COUNT(o_orderkey));
Question: Identify the names of the top 3 customers with the highest number of orders of all time and calculate for the average total price per order of each customers.
SQL: SELECT t.c_name, t.res FROM ( SELECT customer.c_name, sum(orders.o_totalprice) / count(orders.o_orderkey) AS res , count(orders.o_orderkey) AS num FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey GROUP BY orders.o_custkey ) AS t ORDER BY t.num DESC LIMIT 3
Database: retails
Note: items shipped on 4th December, 1993 refer to l_linenumber where l_shipdate = '1993-12-04';
Question: How many items were shipped on 4th December, 1993?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_shipdate = '1993-12-04'
Database: retails
Note: the highest total price refers to MAX(o_totalprice);
Question: What was the order date of items with the highest total price?
SQL: SELECT o_orderdate FROM orders WHERE o_totalprice = ( SELECT max(o_totalprice) FROM orders )
Database: retails
Note: DIVIDE(COUNT(c_custkey where c_acctbal < 0), COUNT(c_custkey)) as percentage;
Question: Calculate the percentage of customers' accounts in debt.
SQL: SELECT cast(sum(iif(c_acctbal < 0, 1, 0)) AS REAL) * 100 / count(c_custkey) FROM customer
Database: retails
Note: supplies nearly out of stock refer to ps_partkey where ps_availqty < 10;
Question: How many part supplies were nearly out of stock?
SQL: SELECT count(ps_suppkey) FROM partsupp WHERE ps_availqty < 10
Database: retails
Note: DIVIDE(COUNT(p_partkey where p_mfgr = 'Manufacturer#3'), COUNT(p_partkey)) as percentage;
Question: Calculate the percentage of manufactured parts by Manufacturer#3.
SQL: SELECT cast(sum(iif(p_mfgr = 'Manufacturer#3', 1, 0)) AS REAL) * 100 / count(p_partkey) FROM part
Database: retails
Note: p_type = 'MEDIUM PLATED BRASS'; parts name refer to p_name;
Question: List any five parts name in Medium Plated Brass.
SQL: SELECT p_name FROM part WHERE p_type = 'MEDIUM PLATED BRASS' LIMIT 5
Database: retails
Note: orders shipped in November, 1998 refer to o_orderkey where l_shipdate LIKE '1998-11-%'; by air refers to l_shipmode = 'AIR'; the order is urgent if o_orderpriority = '1-URGENT' ;
Question: Among the orders shipped in November, 1998 by air, how many orders were urgent?
SQL: SELECT count(orders.o_orderkey) FROM orders INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE lineitem.l_shipmode = 'AIR' AND orders.o_orderpriority = '1-URGENT' AND substr(lineitem.l_shipdate, 1, 7) = '1998-11'
Database: retails
Note: customers refer to c_custkey; India is the name of the nation which refers to n_name = 'INDIA';
Question: How many customers are there in India?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'INDIA'
Database: retails
Note: 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;
Question: Among the customers from Morocco, how many customers were in debt?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_acctbal < 0 AND nation.n_name = 'MOROCCO'
Database: retails
Note: Africa refers to r_name = 'Africa';
Question: List down the nation keys and names in Africa.
SQL: SELECT nation.n_name, nation.n_nationkey FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE region.r_name = 'AFRICA'
Database: retails
Note: customer#000000013 is the name of the customer which refers to c_name;
Question: Calculate the total price of orders by Customer#000000013.
SQL: SELECT sum(orders.o_totalprice) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_name = 'Customer#000000013'
Database: retails
Note: items customer#000021159 order refer to l_linenumber where c_name = 'customer#000021159'; SUM(MULTIPLY(MULTIPLY(l_extendedprice, SUBTRACT(1, l_discount)), SUM(1, l_tax))) where c_name = 'customer#000021159';
Question: How many items did Customer#000021159 order? Calculate those items total charges.
SQL: SELECT count(orders.o_orderkey), sum(lineitem.l_extendedprice * (1 - lineitem.l_discount) * (1 + lineitem.l_tax)) FROM customer INNER JOIN orders ON customer.c_custkey = orders.o_custkey INNER JOIN lineitem ON orders.o_orderkey = lineitem.l_orderkey WHERE customer.c_name = 'Customer#000021159' GROUP BY lineitem.l_linenumber
Database: retails
Note: SUBTRACT(MULTIPLY(l_extendedprice, (SUBTRACT(1, l_discount)), MULTIPLY(ps_supplycost, l_quantity))) where p_name = 'chocolate floral blue coral cyan';
Question: Calculate the total profit made by chocolate floral blue coral cyan.
SQL: SELECT sum(lineitem.l_extendedprice * (1 - lineitem.l_discount) - partsupp.ps_supplycost * lineitem.l_quantity) FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey INNER JOIN lineitem ON partsupp.ps_partkey = lineitem.l_partkey AND partsupp.ps_suppkey = lineitem.l_suppkey WHERE part.p_name = 'chocolate floral blue coral cyan'
Database: retails
Note: DIVIDE(COUNT(s_suppkey where n_name = 'GERMANY'), COUNT(s_suppkey)) as percentage;
Question: Calculate the percentage of suppliers in Germany.
SQL: SELECT cast(sum(iif(nation.n_name = 'GERMANY', 1, 0)) AS REAL) * 100 / count(supplier.s_suppkey) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE supplier.s_acctbal < 0
Database: retails
Note: p_name = 'smoke red pale saddle plum'; the suppliers' names refer to s_name;
Question: List the suppliers' names which supplied smoke red pale saddle plum.
SQL: SELECT supplier.s_name FROM part INNER JOIN partsupp ON part.p_partkey = partsupp.ps_partkey INNER JOIN supplier ON partsupp.ps_suppkey = supplier.s_suppkey WHERE part.p_name = 'smoke red pale saddle plum'
Database: retails
Note: suppliers from Middle East region refer to s_name where r_name = 'MIDDLE EAST'; in debt refers to s_acctbal < 0;
Question: Among the suppliers from Middle East region, how many suppliers were in debt?
SQL: SELECT count(supplier.s_name) FROM region INNER JOIN nation ON region.r_regionkey = nation.n_regionkey INNER JOIN supplier ON nation.n_nationkey = supplier.s_nationkey WHERE supplier.s_acctbal < 0 AND region.r_name = 'MIDDLE EAST'
Database: retails
Note: shipped by rail on 1st December, 1995 refers to l_shipmode = 'RAIL' where l_shipdate = '1995-12-01'; part names with 10% discount refer to p_name where l_discount = 0.1;
Question: Among the parts shipped by rail on 1st December, 1995, list part names with 10% discount.
SQL: SELECT part.p_name FROM partsupp INNER JOIN part ON partsupp.ps_partkey = part.p_partkey INNER JOIN lineitem ON partsupp.ps_partkey = lineitem.l_partkey WHERE lineitem.l_discount = 0.1 AND lineitem.l_shipdate = '1995-12-01' AND lineitem.l_shipmode = 'RAIL'
Database: retails
Note: supplier#000000018 is the name of supplier which refers to s_name; supply costs above 900 refer to ps_supplycost > 900;
Question: Among the parts supplied by Supplier#000000018, provide parts names which had supply costs above 900.
SQL: SELECT part.p_name FROM partsupp INNER JOIN part ON partsupp.ps_partkey = part.p_partkey INNER JOIN supplier ON partsupp.ps_suppkey = supplier.s_suppkey WHERE partsupp.ps_supplycost > 900 AND supplier.s_name = 'Supplier#000000018'
Database: retails
Note: orders shipped in 1994 refer to l_orderkey where year(l_shipdate) = 1994;
Question: How many orders were shipped in 1994?
SQL: SELECT count(l_orderkey) FROM lineitem WHERE strftime('%Y', l_shipdate) = '1994'
Database: retails
Note: shipped by rail refers to l_shipmode = 'RAIL'; quantity less than 30 refers to l_quantity < 30;
Question: How many of the line items have been shipped by rail with a quantity less than 30?
SQL: SELECT count(l_linenumber) FROM lineitem WHERE l_quantity < 30 AND l_shipmode = 'RAIL'
Database: retails
Note: furniture market segment refers to c_mktsegment = 'FURNITURE';
Question: Among the customers in the furniture market segment, how many of them have a nation key of 1?
SQL: SELECT count(c_custkey) FROM customer WHERE c_mktsegment = 'FURNITURE' AND c_nationkey = 1
Database: retails
Note: phone number of the customer refers to c_phone; the highest account balance refers to MAX(c_acctbal);
Question: Give the phone number of the customer with the highest account balance.
SQL: SELECT c_phone FROM customer ORDER BY c_acctbal DESC LIMIT 1
Database: retails
Note: order with the highest total price refers to MAX(o_totalprice);
Question: What is the order priority of the order with the highest total price?
SQL: SELECT o_orderpriority FROM orders WHERE o_totalprice = ( SELECT max(o_totalprice) FROM orders )
Database: retails
Note: orders refer to o_orderkey; the United States is the name of the nation which refers to n_name = 'UNITED STATES';
Question: What is the total number of orders made by customers in United States?
SQL: SELECT count(orders.o_orderkey) FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'UNITED STATES'
Database: retails
Note: customers refer to c_custkey; Brazil is the name of the nation which refers to n_name = 'BRAZIL'; c_mktsegment = 'automobile';
Question: Among the customers from Brazil, how many customers are in automobile market segment?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_mktsegment = 'AUTOMOBILE' AND nation.n_name = 'BRAZIL'
Database: retails
Note: order comments refer to o_comment; c_mktsegment = 'Furniture';
Question: Provide the order comments for at least 5 orders made by customers in the furniture segment.
SQL: SELECT orders.o_comment FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE customer.c_mktsegment = 'Furniture' LIMIT 5
Database: retails
Note: countries in Asia refer to n_name where r_name = 'ASIA';
Question: List down the countries that are located in Asia.
SQL: SELECT nation.n_name FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE region.r_name = 'ASIA'
Database: retails
Note: r_comment = 'furiously express accounts wake sly';
Question: Name the countries that belong in the region with comment description "furiously express accounts wake sly".
SQL: SELECT nation.n_name FROM nation INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE region.r_comment = 'furiously express accounts wake sly'
Database: retails
Note: suppliers refer to s_suppkey; Germany is the name of the nation which refers to n_name = 'GERMANY';
Question: What is the total number of suppliers from Germany?
SQL: SELECT count(supplier.s_suppkey) FROM supplier INNER JOIN nation ON supplier.s_nationkey = nation.n_nationkey WHERE nation.n_name = 'GERMANY'
Database: retails
Note: customers in Asia refer to n_name where r_name = 'ASIA'; customers in debt refer to c_acctbal < 0;
Question: Among the customers in Asia, how many customers are in debt?
SQL: SELECT count(nation.n_name) FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE customer.c_acctbal < 0 AND region.r_name = 'ASIA'
Database: retails
Note: phone number of the customer refers to c_phone; the highest total price refers to MAX(o_totalprice);
Question: Provide the phone number of the customer with the highest total price in an order.
SQL: SELECT customer.c_phone FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey ORDER BY orders.o_totalprice DESC LIMIT 1
Database: retails
Note: products refer to l_partkey; retail price greater than 1,000 refers to p_retailprice > 1000; shipped via ship refers to l_shipmode = 'SHIP';
Question: Among the products that have a retail price greater than 1,000, how many products were shipped via ship?
SQL: SELECT count(partsupp.ps_suppkey) FROM partsupp INNER JOIN lineitem ON partsupp.ps_suppkey = lineitem.l_suppkey INNER JOIN part ON partsupp.ps_partkey = part.p_partkey WHERE part.p_retailprice > 1000 AND lineitem.l_shipmode = 'SHIP'
Database: retails
Note: name of the customer refers to c_name; total order price of 199180.63 refers o_totalprice = 199180.63; marketing segment refers to c_mktsegment;
Question: What is the name and marketing segment of the customer with the total order price of 199180.63?
SQL: SELECT customer.c_name, customer.c_mktsegment FROM orders INNER JOIN customer ON orders.o_custkey = customer.c_custkey WHERE orders.o_totalprice = 199180.63
Database: retails
Note: nation refers to n_name; region refers to r_name; address of wH55UnX7 VI refers to c_address = 'wH55UnX7 VI';
Question: Provide the nation and region of the customer with the address of wH55UnX7 VI?
SQL: SELECT nation.n_name, region.r_name FROM nation INNER JOIN customer ON nation.n_nationkey = customer.c_nationkey INNER JOIN region ON nation.n_regionkey = region.r_regionkey WHERE customer.c_address = 'wH55UnX7 VI'
Database: retails
Note: 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;
Question: Among all the customers in Brazil, how many of them have an account balance of less than 1000?
SQL: SELECT count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE nation.n_name = 'BRAZIL' AND customer.c_acctbal < 1000
Database: retails
Note: country name refers to n_name; building marketing segment refers to c_mktsegment = 'BUILDING'; account balance greater than 80% of the average account balance of all customers refers to c_acctbal > MULTIPLY(AVG(c_acctbal), 0.8);
Question: List the country name of the customers in the building marketing segment with an account balance greater than 80% of the average account balance of all customers.
SQL: SELECT nation.n_name FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey INNER JOIN ( SELECT avg(c_acctbal) * 0.8 AS avg_acctbal FROM customer ) AS t3 WHERE customer.c_acctbal > t3.avg_acctbal
Database: retails
Note: DIVIDE(COUNT(c_custkey where n_name = 'United States' and c_acctbal < 4000), COUNT(c_custkey where c_acctbal < 4000)) as percentage;
Question: Among the customers with an account balance lower than 4000, what is the percentage of the customers in the US?
SQL: SELECT cast(sum(iif(nation.n_name = 'United States', 1, 0)) AS REAL) * 100 / count(customer.c_custkey) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey WHERE customer.c_acctbal < 4000
Database: retails
Note: 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;
Question: Give the name and phone number of the customers who have more than 9000 account balance.
SQL: SELECT c_name, c_phone FROM customer WHERE c_acctbal > 9000