question_id
int64 1
75.7k
| db_id
stringclasses 33
values | db_name
stringclasses 4
values | question
stringlengths 19
259
| partition
stringclasses 4
values | difficulty
stringclasses 3
values | SQL
stringlengths 25
862
|
|---|---|---|---|---|---|---|
501
|
retails
|
bird
|
Among all the customers in Germany, how many of them have an account balance of over 1000?
|
train
|
hard
|
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 = 'germany' AND t1.c_acctbal > 1000
|
502
|
retails
|
bird
|
How many orders in total are made by customers in Germany?
|
train
|
hard
|
SELECT COUNT(t2.c_custkey) FROM nation AS t1 INNER JOIN customer AS t2 ON t1.n_nationkey = t2.c_nationkey INNER JOIN orders AS t3 ON t2.c_custkey = t3.o_custkey WHERE t1.n_name = 'germany'
|
503
|
retails
|
bird
|
What is the total price of all the orders made by customers in Germany?
|
train
|
hard
|
SELECT SUM(t3.o_totalprice) FROM nation AS t1 INNER JOIN customer AS t2 ON t1.n_nationkey = t2.c_nationkey INNER JOIN orders AS t3 ON t2.c_custkey = t3.o_custkey WHERE t1.n_name = 'germany'
|
504
|
retails
|
bird
|
Among the orders made by customers in Germany, which one of them has the highest priority in delivery? Please give its order key.
|
train
|
hard
|
SELECT t3.o_orderkey FROM nation AS t1 INNER JOIN customer AS t2 ON t1.n_nationkey = t2.c_nationkey INNER JOIN orders AS t3 ON t2.c_custkey = t3.o_custkey WHERE t1.n_name = 'germany' ORDER BY t3.o_orderdate LIMIT 1
|
505
|
retails
|
bird
|
What is the average price of the orders made by a customer in Germany?
|
train
|
hard
|
SELECT AVG(t3.o_totalprice) FROM nation AS t1 INNER JOIN customer AS t2 ON t1.n_nationkey = t2.c_nationkey INNER JOIN orders AS t3 ON t2.c_custkey = t3.o_custkey WHERE t1.n_name = 'germany'
|
506
|
retails
|
bird
|
Among all the customers, what is the percentage of the customer's nation being Germany?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.n_name = 'germany', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.c_custkey) FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_nationkey = t2.n_nationkey
|
507
|
retails
|
bird
|
How many countries are there in the No.2 region?
|
train
|
easy
|
SELECT COUNT(n_nationkey) FROM nation WHERE n_regionkey = 2
|
508
|
retails
|
bird
|
Which country does supplier No.34 come from?
|
train
|
hard
|
SELECT t2.n_name FROM supplier AS t1 INNER JOIN nation AS t2 ON t1.s_nationkey = t2.n_nationkey WHERE t1.s_suppkey = 34
|
509
|
retails
|
bird
|
Which region does "Supplier#000000129" belong to?
|
train
|
hard
|
SELECT t3.r_name FROM nation AS t1 INNER JOIN supplier AS t2 ON t1.n_nationkey = t2.s_nationkey INNER JOIN region AS t3 ON t1.n_regionkey = t3.r_regionkey WHERE t2.s_name = 'supplier#000000129'
|
510
|
retails
|
bird
|
What is the nationality of "Customer#000000055"?
|
train
|
hard
|
SELECT t2.n_name FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_name = 'customer#000000055'
|
511
|
retails
|
bird
|
Give customer No.106936's region name.
|
train
|
hard
|
SELECT 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_custkey = 106936
|
512
|
retails
|
bird
|
Give the number of Moroccan customers whose account is in debt.
|
train
|
hard
|
SELECT COUNT(t1.c_name) FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_nationkey = t2.n_nationkey WHERE t2.n_name = 'morocco' AND t1.c_acctbal < 0
|
513
|
retails
|
bird
|
For the order with the total price of 231499.38, what was the discounted price for supplier No. 9397?
|
train
|
hard
|
SELECT t1.l_extendedprice * (1 - t1.l_discount) AS discounterprice FROM lineitem AS t1 INNER JOIN orders AS t2 ON t2.o_orderkey = t1.l_orderkey WHERE t1.l_suppkey = 9397 AND t2.o_totalprice = 231499.38
|
514
|
retails
|
bird
|
For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id.
|
train
|
hard
|
SELECT t2.l_suppkey FROM orders AS t1 INNER JOIN lineitem AS t2 ON t1.o_orderkey = t2.l_orderkey WHERE t1.o_totalprice = 218195.43 AND t2.l_returnflag = 'r'
|
515
|
retails
|
bird
|
Clerk#000000936 dealt with a "Not Specified" order on 1995/3/13, what was the charge for the part of the order shipped by truck?
|
train
|
hard
|
SELECT t2.l_extendedprice * (1 - t2.l_discount) * (1 + t2.l_tax) AS num FROM orders AS t1 INNER JOIN lineitem AS t2 ON t1.o_orderkey = t2.l_orderkey WHERE t1.o_clerk = 'clerk#000000936' AND t2.l_shipmode = 'truck' AND t1.o_orderstatus = '4-not specified' AND t1.o_orderdate = '1995-03-13'
|
516
|
retails
|
bird
|
Customer No.129301 made an order on 1996/7/27, what was the delivery time for the first part of that order?
|
train
|
hard
|
SELECT JULIANDAY(t2.l_receiptdate) - JULIANDAY(t2.l_commitdate) FROM orders AS t1 INNER JOIN lineitem AS t2 ON t1.o_orderkey = t2.l_orderkey WHERE t1.o_custkey = '129301' AND t1.o_orderdate = '1996-07-27'
|
517
|
retails
|
bird
|
Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10.
|
train
|
hard
|
SELECT t2.c_name FROM orders AS t1 INNER JOIN customer AS t2 ON t1.o_custkey = t2.c_custkey WHERE t1.o_orderdate = '1997-12-10' AND t1.o_clerk = 'clerk#000000803'
|
518
|
retails
|
bird
|
Calculates the profit processed by Supplier No. 7414 on order No. 817154.
|
train
|
hard
|
SELECT t1.l_extendedprice * (1 - t1.l_discount) - t2.ps_supplycost * t1.l_quantity FROM lineitem AS t1 INNER JOIN partsupp AS t2 ON t1.l_suppkey = t2.ps_suppkey WHERE t1.l_suppkey = 7414 AND t1.l_orderkey = 817154
|
519
|
retails
|
bird
|
Which country has the most number of suppliers whose account is in debt?
|
train
|
hard
|
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
|
520
|
retails
|
bird
|
What is the percentage of the European countries among the given countries?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.r_name = 'europe', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.n_name) FROM nation AS t1 INNER JOIN region AS t2 ON t1.n_regionkey = t2.r_regionkey
|
521
|
retails
|
bird
|
Give the percentage of Japanese suppliers whose account is in debt.
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.n_name = 'japan', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.s_name) FROM supplier AS t1 INNER JOIN nation AS t2 ON t1.s_nationkey = t2.n_nationkey WHERE t1.s_acctbal < 0
|
522
|
retails
|
bird
|
What is the name of the customer with the highest amount of debt?
|
train
|
easy
|
SELECT c_name FROM customer WHERE c_acctbal = (SELECT MIN(c_acctbal) FROM customer)
|
523
|
retails
|
bird
|
How many orders were shipped in 1998?
|
train
|
easy
|
SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%y', l_shipdate) = '1998'
|
524
|
retails
|
bird
|
How many customers are in debt?
|
train
|
easy
|
SELECT COUNT(c_custkey) FROM customer WHERE c_acctbal < 0
|
525
|
retails
|
bird
|
How many items that were shipped via air were returned in 1994?
|
train
|
medium
|
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_returnflag = 'r' AND l_shipmode = 'air' AND STRFTIME('%y', l_shipdate) = '1994'
|
526
|
retails
|
bird
|
How many customers are in the automobile market segment?
|
train
|
easy
|
SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'automobile'
|
527
|
retails
|
bird
|
What are the top 2 order keys of the item with the highest amount of extended price?
|
train
|
hard
|
SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice DESC LIMIT 2
|
528
|
retails
|
bird
|
When was the order with the highest amount of total price shipped?
|
train
|
hard
|
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
|
529
|
retails
|
bird
|
In which country do most of the customers come from?
|
train
|
hard
|
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
|
530
|
retails
|
bird
|
How many urgent orders were shipped the next day?
|
train
|
hard
|
SELECT COUNT(t2.o_orderkey) FROM lineitem AS t1 INNER JOIN orders AS t2 ON t2.o_orderkey = t1.l_orderkey WHERE JULIANDAY(t1.l_shipdate) - JULIANDAY(t2.o_orderdate) = 1 AND t2.o_orderpriority = '1-urgent'
|
531
|
retails
|
bird
|
How many in debt customers in the household market segment are from Russia?
|
train
|
hard
|
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'
|
532
|
retails
|
bird
|
How many suppliers are from Japan?
|
train
|
hard
|
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'
|
533
|
retails
|
bird
|
How many orders shipped via ship have a medium priority?
|
train
|
hard
|
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'
|
534
|
retails
|
bird
|
Among the customers from the United States, which market segment has the highest number of customers?
|
train
|
hard
|
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
|
535
|
retails
|
bird
|
What are the countries in the region of Asia?
|
train
|
hard
|
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'
|
536
|
retails
|
bird
|
What are the names of the parts manufactured by manufacturer 3 that have a supply cost of 1,000?
|
train
|
hard
|
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'
|
537
|
retails
|
bird
|
How many countries are there in the region whose comment description is "asymptotes sublate after the r."
|
train
|
hard
|
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'
|
538
|
retails
|
bird
|
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?
|
train
|
hard
|
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'
|
539
|
retails
|
bird
|
How much is the profit for smoke turquoise purple blue salmon that was delivered in person on 5/7/1996?
|
train
|
hard
|
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'
|
540
|
retails
|
bird
|
What is the average price before discount of the top 10 orders with the highest total price?
|
train
|
hard
|
SELECT CAST(SUM(t2.l_extendedprice) AS REAL) / 10 FROM orders AS t1 INNER JOIN lineitem AS t2 ON t1.o_orderkey = t2.l_orderkey ORDER BY t1.o_totalprice DESC LIMIT 10
|
541
|
retails
|
bird
|
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.
|
train
|
hard
|
SELECT t.c_name, t.res FROM (SELECT t2.c_name, CAST(SUM(t1.o_totalprice) AS REAL) / COUNT(t1.o_orderkey) AS res, COUNT(t1.o_orderkey) AS num FROM orders AS t1 INNER JOIN customer AS t2 ON t1.o_custkey = t2.c_custkey GROUP BY t1.o_custkey) AS t ORDER BY t.num DESC LIMIT 3
|
542
|
retails
|
bird
|
How many items were shipped on 4th December, 1993?
|
train
|
easy
|
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipdate = '1993-12-04'
|
543
|
retails
|
bird
|
What was the order date of items with the highest total price?
|
train
|
medium
|
SELECT o_orderdate FROM orders WHERE o_totalprice = (SELECT MAX(o_totalprice) FROM orders)
|
544
|
retails
|
bird
|
Calculate the percentage of customers' accounts in debt.
|
train
|
easy
|
SELECT CAST(CAST(SUM(IIF(c_acctbal < 0, 1, 0)) AS REAL) * 100 AS REAL) / COUNT(c_custkey) FROM customer
|
545
|
retails
|
bird
|
How many part supplies were nearly out of stock?
|
train
|
easy
|
SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10
|
546
|
retails
|
bird
|
Calculate the percentage of manufactured parts by Manufacturer#3.
|
train
|
easy
|
SELECT CAST(CAST(SUM(IIF(p_mfgr = 'manufacturer#3', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(p_partkey) FROM part
|
547
|
retails
|
bird
|
List any five parts name in Medium Plated Brass.
|
train
|
easy
|
SELECT p_name FROM part WHERE p_type = 'medium plated brass' LIMIT 5
|
548
|
retails
|
bird
|
Among the orders shipped in November, 1998 by air, how many orders were urgent?
|
train
|
hard
|
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 = 'air' AND t1.o_orderpriority = '1-urgent' AND SUBSTRING(t2.l_shipdate, 1, 7) = '1998-11'
|
549
|
retails
|
bird
|
How many customers are there in India?
|
train
|
hard
|
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'
|
550
|
retails
|
bird
|
Among the customers from Morocco, how many customers were in debt?
|
train
|
hard
|
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'
|
551
|
retails
|
bird
|
List down the nation keys and names in Africa.
|
train
|
hard
|
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'
|
552
|
retails
|
bird
|
Calculate the total price of orders by Customer#000000013.
|
train
|
hard
|
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'
|
553
|
retails
|
bird
|
How many items did Customer#000021159 order? Calculate those items total charges.
|
train
|
hard
|
SELECT COUNT(t2.o_orderkey), SUM(t3.l_extendedprice * (1 - t3.l_discount) * (1 + t3.l_tax)) FROM customer AS t1 INNER JOIN orders AS t2 ON t1.c_custkey = t2.o_custkey INNER JOIN lineitem AS t3 ON t2.o_orderkey = t3.l_orderkey WHERE t1.c_name = 'customer#000021159' GROUP BY t3.l_linenumber
|
554
|
retails
|
bird
|
Calculate the total profit made by chocolate floral blue coral cyan.
|
train
|
hard
|
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'
|
555
|
retails
|
bird
|
Calculate the percentage of suppliers in Germany.
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.n_name = 'germany', 1, 0)) AS REAL) * 100 AS REAL) / 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
|
556
|
retails
|
bird
|
List the suppliers' names which supplied smoke red pale saddle plum.
|
train
|
hard
|
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'
|
557
|
retails
|
bird
|
Among the suppliers from Middle East region, how many suppliers were in debt?
|
train
|
hard
|
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'
|
558
|
retails
|
bird
|
Among the parts shipped by rail on 1st December, 1995, list part names with 10% discount.
|
train
|
hard
|
SELECT t2.p_name FROM partsupp AS t1 INNER JOIN part AS t2 ON t1.ps_partkey = t2.p_partkey INNER JOIN lineitem AS t3 ON t1.ps_partkey = t3.l_partkey WHERE t3.l_discount = 0.1 AND t3.l_shipdate = '1995-12-01' AND t3.l_shipmode = 'rail'
|
559
|
retails
|
bird
|
Among the parts supplied by Supplier#000000018, provide parts names which had supply costs above 900.
|
train
|
hard
|
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'
|
560
|
retails
|
bird
|
How many orders were shipped in 1994?
|
train
|
easy
|
SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%y', l_shipdate) = '1994'
|
561
|
retails
|
bird
|
How many of the line items have been shipped by rail with a quantity less than 30?
|
train
|
medium
|
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity < 30 AND l_shipmode = 'rail'
|
562
|
retails
|
bird
|
Among the customers in the furniture market segment, how many of them have a nation key of 1?
|
train
|
medium
|
SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'furniture' AND c_nationkey = 1
|
563
|
retails
|
bird
|
Give the phone number of the customer with the highest account balance.
|
train
|
hard
|
SELECT c_phone FROM customer ORDER BY c_acctbal DESC LIMIT 1
|
564
|
retails
|
bird
|
What is the order priority of the order with the highest total price?
|
train
|
medium
|
SELECT o_orderpriority FROM orders WHERE o_totalprice = (SELECT MAX(o_totalprice) FROM orders)
|
565
|
retails
|
bird
|
What is the total number of orders made by customers in United States?
|
train
|
hard
|
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'
|
566
|
retails
|
bird
|
Among the customers from Brazil, how many customers are in automobile market segment?
|
train
|
hard
|
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'
|
567
|
retails
|
bird
|
Provide the order comments for at least 5 orders made by customers in the furniture segment.
|
train
|
hard
|
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' LIMIT 5
|
568
|
retails
|
bird
|
List down the countries that are located in Asia.
|
train
|
hard
|
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'
|
569
|
retails
|
bird
|
Name the countries that belong in the region with comment description "furiously express accounts wake sly".
|
train
|
hard
|
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'
|
570
|
retails
|
bird
|
What is the total number of suppliers from Germany?
|
train
|
hard
|
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'
|
571
|
retails
|
bird
|
Among the customers in Asia, how many customers are in debt?
|
train
|
hard
|
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'
|
572
|
retails
|
bird
|
Provide the phone number of the customer with the highest total price in an order.
|
train
|
hard
|
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
|
573
|
retails
|
bird
|
Among the products that have a retail price greater than 1,000, how many products were shipped via ship?
|
train
|
hard
|
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'
|
574
|
retails
|
bird
|
What is the name and marketing segment of the customer with the total order price of 199180.63?
|
train
|
hard
|
SELECT t2.c_name, t2.c_mktsegment FROM orders AS t1 INNER JOIN customer AS t2 ON t1.o_custkey = t2.c_custkey WHERE t1.o_totalprice = 199180.63
|
575
|
retails
|
bird
|
Provide the nation and region of the customer with the address of wH55UnX7 VI?
|
train
|
hard
|
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'
|
576
|
retails
|
bird
|
Among all the customers in Brazil, how many of them have an account balance of less than 1000?
|
train
|
hard
|
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
|
577
|
retails
|
bird
|
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.
|
train
|
hard
|
SELECT t2.n_name FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_nationkey = t2.n_nationkey INNER JOIN (SELECT AVG(c_acctbal) * 0.8 AS avg_acctbal FROM customer) AS t3 WHERE t1.c_acctbal > t3.avg_acctbal
|
578
|
retails
|
bird
|
Among the customers with an account balance lower than 4000, what is the percentage of the customers in the US?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.n_name = 'united states', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.c_custkey) FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_nationkey = t2.n_nationkey WHERE t1.c_acctbal < 4000
|
579
|
retails
|
bird
|
Give the name and phone number of the customers who have more than 9000 account balance.
|
train
|
easy
|
SELECT c_name, c_phone FROM customer WHERE c_acctbal > 9000
|
580
|
retails
|
bird
|
What is the average number of items shipped each day in April of 1994?
|
train
|
medium
|
SELECT AVG(l_linenumber) FROM lineitem WHERE l_shipdate BETWEEN '1994-01-01' AND '1994-01-30'
|
581
|
retails
|
bird
|
List the order key of the orders with a total price between 200000 and 300000.
|
train
|
medium
|
SELECT o_orderkey FROM orders WHERE o_totalprice BETWEEN 200000 AND 300000
|
582
|
retails
|
bird
|
Find and list the part key of the parts which has an above-average retail price.
|
train
|
easy
|
SELECT p_partkey FROM part WHERE p_retailprice > (SELECT AVG(p_retailprice) FROM part)
|
583
|
retails
|
bird
|
Calculate the percentage of part supply that costs more than 500.
|
train
|
easy
|
SELECT CAST(CAST(SUM(IIF(ps_supplycost > 500, 1, 0)) AS REAL) * 100 AS REAL) / COUNT(ps_suppkey) FROM partsupp
|
584
|
retails
|
bird
|
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.
|
train
|
hard
|
SELECT s_suppkey, s_acctbal FROM supplier ORDER BY s_acctbal DESC LIMIT 10
|
585
|
retails
|
bird
|
How many customers who are not in debt ordered an urgent order?
|
train
|
hard
|
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'
|
586
|
retails
|
bird
|
List the name and phone number of customers in India who have an above-average account balance.
|
train
|
hard
|
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
|
587
|
retails
|
bird
|
In the parts supply by Supplier#000000654, list the top five parts with the most supply cost in descending order of supply cost.
|
train
|
hard
|
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
|
588
|
retails
|
bird
|
What percentage of customers from France is in the automobile segment?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t1.c_mktsegment = 'automobile', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.c_name) FROM customer AS t1 INNER JOIN nation AS t2 ON t1.c_nationkey = t2.n_nationkey WHERE t2.n_name = 'france'
|
589
|
retails
|
bird
|
Name the part which is most profitable.
|
train
|
hard
|
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
|
590
|
retails
|
bird
|
List the names of the countries with the below-average number of customers in ascending order of customer numbers.
|
train
|
hard
|
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 CAST(COUNT(customer.c_name) AS REAL) / COUNT(DISTINCT nation.n_name) FROM customer INNER JOIN nation ON customer.c_nationkey = nation.n_nationkey) ORDER BY COUNT(t1.c_name)
|
591
|
retails
|
bird
|
What percentage of customers from the African region is in the household segment?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t2.r_name = 'africa', 1, 0)) AS REAL) * 100 AS REAL) / COUNT(t1.n_nationkey) FROM nation AS t1 INNER JOIN region AS t2 ON t1.n_regionkey = t2.r_regionkey INNER JOIN customer AS t3 ON t1.n_nationkey = t3.c_nationkey WHERE t3.c_mktsegment = 'household'
|
592
|
retails
|
bird
|
List the name of the top ten items with the most quantity available in the descending order of availability.
|
train
|
hard
|
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
|
593
|
retails
|
bird
|
Calculate the difference in the average retail price of parts shipped via ship and air.
|
train
|
hard
|
SELECT (CAST(SUM(IIF(t3.l_shipmode = 'ship', t1.p_retailprice, 0)) AS REAL) / SUM(IIF(t3.l_shipmode = 'ship', 1, 0))) - (CAST(SUM(IIF(t3.l_shipmode = 'air', t1.p_retailprice, 0)) AS REAL) / SUM(IIF(t3.l_shipmode = 'air', 1, 0))) 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
|
594
|
retails
|
bird
|
What is the average discount for the parts made by Manufacturer#5?
|
train
|
hard
|
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'
|
595
|
retails
|
bird
|
In the parts shipped by rail, how many are of medium priority?
|
train
|
hard
|
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'
|
596
|
retails
|
bird
|
Among the suppliers in the European region, what percentage have a below-average account balance?
|
train
|
hard
|
SELECT CAST(CAST(SUM(IIF(t3.s_acctbal < (SELECT AVG(supplier.s_acctbal) FROM supplier), 1, 0)) AS REAL) * 100 AS REAL) / 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'
|
597
|
retails
|
bird
|
Calculate the difference in the average number of low-priority orders shipped by truck in each month of 1995 and 1996.
|
train
|
hard
|
SELECT (CAST(SUM(IIF(STRFTIME('%y', t2.l_shipdate) = 1995, 1, 0)) AS REAL) / 12) - (CAST(SUM(IIF(STRFTIME('%y', t2.l_shipdate) = 1996, 1, 0)) AS REAL) / 12) FROM orders AS t1 INNER JOIN lineitem AS t2 ON t1.o_orderkey = t2.l_orderkey WHERE t1.o_orderpriority = '5-low' AND t2.l_shipmode = 'truck'
|
598
|
retails
|
bird
|
List by their id all customers who have a debit balance in their accounts.
|
train
|
easy
|
SELECT c_custkey FROM customer WHERE c_acctbal < 0
|
599
|
retails
|
bird
|
List by order number the 3 items with the lowest price after applying the discount.
|
train
|
hard
|
SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice * (1 - l_discount) LIMIT 3
|
600
|
retails
|
bird
|
How many orders of more than 10 items have been returned?
|
train
|
medium
|
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 10 AND l_returnflag = 'r'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.