problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: How much is the profit for smoke turquoise purple blue salmon that was delivered in person on 5/7/1996?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the average price before discount of the top 10 orders with the highest total price?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT SUM(T2.l_extendedprice) / 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
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT T.c_name, T.res FROM ( SELECT T2.c_name, SUM(T1.o_totalprice) / 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
Write SQL query to solve given problem: How many items were shipped on 4th December, 1993?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_shipdate = '1993-12-04'
Write SQL query to solve given problem: What was the order date of items with the highest total price?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT o_orderdate FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders )
Write SQL query to solve given problem: Calculate the percentage of customers' accounts in debt.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(c_acctbal < 0, 1, 0)) AS REAL) * 100 / COUNT(c_custkey) FROM customer
Write SQL query to solve given problem: How many part supplies were nearly out of stock?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(ps_suppkey) FROM partsupp WHERE ps_availqty < 10
Write SQL query to solve given problem: Calculate the percentage of manufactured parts by Manufacturer#3.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(p_mfgr = 'Manufacturer#3', 1, 0)) AS REAL) * 100 / COUNT(p_partkey) FROM part
Write SQL query to solve given problem: List any five parts name in Medium Plated Brass.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT p_name FROM part WHERE p_type = 'MEDIUM PLATED BRASS' LIMIT 5
Write SQL query to solve given problem: Among the orders shipped in November, 1998 by air, how many orders were urgent?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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 SUBSTR(T2.l_shipdate, 1, 7) = '1998-11'
Write SQL query to solve given problem: How many customers are there in India?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the customers from Morocco, how many customers were in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: List down the nation keys and names in Africa.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Calculate the total price of orders by Customer#000000013.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: How many items did Customer#000021159 order? Calculate those items total charges.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Calculate the total profit made by chocolate floral blue coral cyan.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Calculate the percentage of suppliers in Germany.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T2.n_name = 'GERMANY', 1, 0)) AS REAL) * 100 / 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
Write SQL query to solve given problem: List the suppliers' names which supplied smoke red pale saddle plum.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the suppliers from Middle East region, how many suppliers were in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the parts shipped by rail on 1st December, 1995, list part names with 10% discount.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the parts supplied by Supplier#000000018, provide parts names which had supply costs above 900.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: How many orders were shipped in 1994?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%Y', l_shipdate) = '1994'
Write SQL query to solve given problem: How many of the line items have been shipped by rail with a quantity less than 30?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity < 30 AND l_shipmode = 'RAIL'
Write SQL query to solve given problem: Among the customers in the furniture market segment, how many of them have a nation key of 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'FURNITURE' AND c_nationkey = 1
Write SQL query to solve given problem: Give the phone number of the customer with the highest account balance.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_phone FROM customer ORDER BY c_acctbal DESC LIMIT 1
Write SQL query to solve given problem: What is the order priority of the order with the highest total price?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT o_orderpriority FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders )
Write SQL query to solve given problem: What is the total number of orders made by customers in United States?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the customers from Brazil, how many customers are in automobile market segment?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Provide the order comments for at least 5 orders made by customers in the furniture segment.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: List down the countries that are located in Asia.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Name the countries that belong in the region with comment description "furiously express accounts wake sly".. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the total number of suppliers from Germany?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the customers in Asia, how many customers are in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Provide the phone number of the customer with the highest total price in an order.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Among the products that have a retail price greater than 1,000, how many products were shipped via ship?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the name and marketing segment of the customer with the total order price of 199180.63?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Provide the nation and region of the customer with the address of wH55UnX7 VI?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among all the customers in Brazil, how many of them have an account balance of less than 1000?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Among the customers with an account balance lower than 4000, what is the percentage of the customers in the US?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T2.n_name = 'United States', 1, 0)) AS REAL) * 100 / 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
Write SQL query to solve given problem: Give the name and phone number of the customers who have more than 9000 account balance.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_name, c_phone FROM customer WHERE c_acctbal > 9000
Write SQL query to solve given problem: What is the average number of items shipped each day in April of 1994?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT AVG(l_linenumber) FROM lineitem WHERE l_shipdate BETWEEN '1994-01-01' AND '1994-01-30'
Write SQL query to solve given problem: List the order key of the orders with a total price between 200000 and 300000.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT o_orderkey FROM orders WHERE o_totalprice BETWEEN 200000 AND 300000
Write SQL query to solve given problem: Find and list the part key of the parts which has an above-average retail price.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT p_partkey FROM part WHERE p_retailprice > ( SELECT AVG(p_retailprice) FROM part )
Write SQL query to solve given problem: Calculate the percentage of part supply that costs more than 500.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(ps_supplycost > 500, 1, 0)) AS REAL) * 100 / COUNT(ps_suppkey) FROM partsupp
Write SQL query to solve given problem: 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.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT s_suppkey, s_acctbal FROM supplier ORDER BY s_acctbal DESC LIMIT 10
Write SQL query to solve given problem: How many customers who are not in debt ordered an urgent order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: List the name and phone number of customers in India who have an above-average account balance.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: In the parts supply by Supplier#000000654, list the top five parts with the most supply cost in descending order of supply cost.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: What percentage of customers from France is in the automobile segment?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T1.c_mktsegment = 'AUTOMOBILE', 1, 0)) AS REAL) * 100 / 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'
Write SQL query to solve given problem: Name the part which is most profitable.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: List the names of the countries with the below-average number of customers in ascending order of customer numbers.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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)
Write SQL query to solve given problem: What percentage of customers from the African region is in the household segment?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T2.r_name = 'AFRICA', 1, 0)) AS REAL) * 100 / 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'
Write SQL query to solve given problem: List the name of the top ten items with the most quantity available in the descending order of availability.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Calculate the difference in the average retail price of parts shipped via ship and air.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: What is the average discount for the parts made by Manufacturer#5?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: In the parts shipped by rail, how many are of medium priority?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Among the suppliers in the European region, what percentage have a below-average account balance?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T3.s_acctbal < ( SELECT AVG(supplier.s_acctbal) FROM supplier ), 1, 0)) AS REAL) * 100 / 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'
Write SQL query to solve given problem: Calculate the difference in the average number of low-priority orders shipped by truck in each month of 1995 and 1996.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: List by their id all customers who have a debit balance in their accounts.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_custkey FROM customer WHERE c_acctbal < 0
Write SQL query to solve given problem: List by order number the 3 items with the lowest price after applying the discount.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice * (1 - l_discount) LIMIT 3
Write SQL query to solve given problem: How many orders of more than 10 items have been returned?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 10 AND l_returnflag = 'R'
Write SQL query to solve given problem: What is the total price charged for orders shipped by air without shipping instructions?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT l_extendedprice * (1 - l_discount) * (1 + l_tax) AS totalprice FROM lineitem WHERE l_shipmode = 'AIR' AND l_shipinstruct = 'NONE'
Write SQL query to solve given problem: Of the orders with a lower delivery priority, how many have an urgent priority order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(o_orderkey) FROM orders WHERE o_orderpriority = '1-URGENT' GROUP BY o_orderdate ORDER BY o_orderdate DESC LIMIT 1
Write SQL query to solve given problem: How many suppliers from Egypt have a debit balance?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: How many items shipped by REG AIR were ordered on March 22, 1995?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: How many European suppliers are there?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: To which segment belongs the customer that made the most orders in April 1994?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT T.c_mktsegment FROM ( SELECT T2.c_mktsegment, COUNT(T1.o_orderkey) AS num FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T1.o_orderdate LIKE '1994-04-%' GROUP BY T1.o_custkey ) AS T ORDER BY T.num DESC LIMIT 1
Write SQL query to solve given problem: Lists all parts supplied by Supplier#000000034.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What are the cost prices of large burnished copper?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: How many clients from Mozambique required orders with a low priority order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Indicate the name of the product that is close to being sold out and that has the lowest cost price.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: How many different clerks have served the customer with the address uFTe2u518et8Q8UC?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Indicate the name of the parts without discount.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: How many suppliers from Germany have left a comment with 'carefully regular packages'?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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%'
Write SQL query to solve given problem: How many products shipped on 19/11/1994 were ordered on 21/09/1994?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Calculate the average profit of prom brushed steel products.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What percentage of customers engaged in the household segment are from Iran?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT CAST(SUM(IIF(T2.n_name = 'IRAN', 1, 0)) AS REAL) * 100 / COUNT(T2.n_name) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD'
Write SQL query to solve given problem: Please state the segment, the name, the address, and the phone number of customer number 3.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_mktsegment, c_name, c_address, c_phone FROM customer WHERE c_custkey = 3
Write SQL query to solve given problem: Please list any three line item numbers that have 10% off.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT l_linenumber FROM lineitem WHERE l_discount = 0.1 LIMIT 3
Write SQL query to solve given problem: How many of the line items that have a quantity greater than 40 have been shipped by air?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(l_linenumber) FROM lineitem WHERE l_quantity > 40 AND l_shipmode = 'AIR'
Write SQL query to solve given problem: Which ship mode has more "deliver in person" instructions, rail or mail?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the total price and the order priority of order number 33?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT o_totalprice, o_orderpriority FROM orders WHERE o_orderkey = 33
Write SQL query to solve given problem: How many orders in 1998 had a total price under 950?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT COUNT(o_orderkey) AS countorders FROM orders WHERE STRFTIME('%Y', o_orderdate) = '1998' AND o_totalprice < 950
Write SQL query to solve given problem: Please list any three customers with debt.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_name FROM customer WHERE c_acctbal < 0 LIMIT 3
Write SQL query to solve given problem: What is the discounted price of line item number 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT l_extendedprice * (1 - l_discount) FROM lineitem WHERE l_linenumber = 1
Write SQL query to solve given problem: What is the difference between the number of returned items and not returned items with the full price of under 16947.7?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT SUM(IIF(l_returnflag = 'A', 1, 0)) - SUM(IIF(l_returnflag = 'N', 1, 0)) AS diff FROM lineitem WHERE l_extendedprice < 16947.7
Write SQL query to solve given problem: What is the supply cost of large plated tin?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Please name any three parts that have an available quantity of more than 9998.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Please list any two parts that come with the wrap bag container and have a supply cost of under 10.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: What is the nationality of supplier number 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: What are the countries that belong to Africa?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Which region has the lowest number of countries?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: How many customers from the furniture segments come from Iraq?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the name of the customer number 93697 with the total order price of 191918.92?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: Which nation and region does the Customer#000000008 come from?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: What is the delivery time and the clerk of order number 6?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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
Write SQL query to solve given problem: How many Japanese suppliers have their accounts in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
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'
Write SQL query to solve given problem: Which customer is the most in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT c_name FROM customer WHERE c_acctbal = ( SELECT MIN(c_acctbal) FROM customer )
Write SQL query to solve given problem: List all the dates of the urgent orders.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retails
SELECT o_orderdate FROM orders WHERE o_orderpriority = '1-URGENT'