problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: Indicate category name of soft drinks, coffees, teas, beers, and ales in description list.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT CategoryName FROM Categories WHERE Description = 'Soft drinks, coffees, teas, beers, and ales' |
Write SQL query to solve given problem: List the phone number of company named Around the Horn.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT Phone FROM Customers WHERE CompanyName = 'Around the Horn' |
Write SQL query to solve given problem: Indicate the fax of the company Blondesddsl pre et fils in Strasbourg city.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT Fax FROM Customers WHERE CompanyName = 'Blondesddsl pre et fils' AND City = 'Strasbourg' |
Write SQL query to solve given problem: Which company name in London city has the most stocked products?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.City = 'London' ORDER BY T1.UnitsInStock DESC LIMIT 1 |
Write SQL query to solve given problem: Which product of Exotic Liquids company that have the highest reorder levels?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Exotic Liquids' ORDER BY T1.ReorderLevel DESC LIMIT 1 |
Write SQL query to solve given problem: Provide the category name of the Chef Anton's Gumbo Mix product that New Orleans Cajun Delights company has.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T3.CategoryName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T1.CompanyName = 'New Orleans Cajun Delights' AND T2.ProductName LIKE 'Chef Anton%s Gumbo Mix' |
Write SQL query to solve given problem: What is the difference in number of unit price from Chef Anton's Cajun Seasoning product and Chef Anton's Gumbo Mix product of New Orleans Cajun Delights company.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT ( SELECT T1.UnitPrice FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'New Orleans Cajun Delights' AND T1.ProductName LIKE 'Chef Anton%s Cajun Seasoning' ) - ( SELECT T1.UnitPrice FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'New Orleans Cajun Delights' AND T1.ProductName LIKE 'Chef Anton%s Gumbo Mix' ) AS calu |
Write SQL query to solve given problem: Which of Cooperativa de Quesos 'Las Cabras' products have a unit price greater than 20?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName LIKE 'Cooperativa de Quesos%' AND T1.UnitPrice > 20 |
Write SQL query to solve given problem: Please indicate the product name of Tokyo Traders company with order quantity greater than 40.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT DISTINCT T2.ProductName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID WHERE T1.CompanyName = 'Tokyo Traders' AND T3.Quantity > 40 |
Write SQL query to solve given problem: List all category name of Exotic Liquids 's product with units in stock over 100.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T3.CategoryName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN Categories AS T3 ON T2.CategoryID = T3.CategoryID WHERE T2.UnitsInStock > 100 AND T1.CompanyName = 'Exotic Liquids' |
Write SQL query to solve given problem: How many product names have order quantity less than 50? Calculate the percentage of orders less than 50 out of total order quantity.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT SUM(CASE WHEN T2.Quantity < 50 THEN 1 ELSE 0 END) , CAST(SUM(IF(T2.Quantity < 50, 1, 0)) AS REAL) / COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID |
Write SQL query to solve given problem: Please indicate total order quantity of product Geitost and calculate the percentage of such product among all the order quantity.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT SUM(IF(T1.ProductName = 'Geitost', 1, 0)) AS sum , CAST(SUM(IF(T1.ProductName = 'Geitost', 1, 0)) AS REAL) / COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID |
Write SQL query to solve given problem: Write the shipping company name with the telephone number of (503) 555-9931.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT CompanyName FROM Shippers WHERE Phone = '(503) 555-9931' |
Write SQL query to solve given problem: Sir Rodney's Marmalade is supplied by which company and who is the contact for this company?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.CompanyName, T2.ContactName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.ProductName LIKE 'Sir Rodney%s Marmalade' |
Write SQL query to solve given problem: How many orders were shipped via Federal Shipping?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShipVia = 3 |
Write SQL query to solve given problem: The product 'Mozzarella di Giovanni' belongs in which category? Include the category's description as well.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.CategoryName, T2.Description FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.ProductName = 'Mozzarella di Giovanni' |
Write SQL query to solve given problem: Which products by Plutzer Lebensmittelgromrkte AG were discontinued and what are their price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.UnitPrice FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Plutzer Lebensmittelgromrkte AG' AND T1.Discontinued = 1 |
Write SQL query to solve given problem: What percentage does the shipment of products by Speedy Express to Sweden make up to the shipping company's total?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT CAST(COUNT(CASE WHEN T1.ShipCountry = 'Sweden' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Speedy Express' |
Write SQL query to solve given problem: How many territory fall into region 1?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(TerritoryID) FROM Territories WHERE RegionID = 1 |
Write SQL query to solve given problem: What are the the total number of territory in each region?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(TerritoryDescription) FROM Territories WHERE RegionID IN (1, 2, 3, 4) GROUP BY RegionID |
Write SQL query to solve given problem: How many products supplied by Plutzer Lebensmittelgromrkte AG that is currently out of stock and on order?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Plutzer Lebensmittelgromrkte AG' AND T1.UnitsInStock = 0 AND T1.UnitsOnOrder = 0 |
Write SQL query to solve given problem: What product have the highest unit price and how many quantity have been being sold?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.ProductName, T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.UnitPrice DESC LIMIT 1 |
Write SQL query to solve given problem: Which employee has created the least order and please indicates the employee's title?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.Title FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID GROUP BY T1.Title ORDER BY COUNT(T2.OrderID) LIMIT 1 |
Write SQL query to solve given problem: What is the most common product ordered by a customer from Germany?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.ProductID FROM Customers AS T1 INNER JOIN `Order Details` AS T2 WHERE T1.Country = 'Germany' GROUP BY T2.ProductID ORDER BY COUNT(T2.ProductID) DESC LIMIT 1 |
Write SQL query to solve given problem: How many subordinates does employee ID 2 have and what is the biggest order in terms of value that his/her subordinates have created?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(T1.EmployeeID), SUM(T3.Quantity * T3.UnitPrice) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID WHERE T1.ReportsTo = 2 ORDER BY SUM(T3.UnitPrice * T3.Quantity) DESC LIMIT 1 |
Write SQL query to solve given problem: Which customer have the biggest purchase in one order and where does this order being ship to?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.CompanyName, T2.ShipCountry FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN `Order Details` AS T3 ON T2.OrderID = T3.OrderID GROUP BY T1.CompanyName, T2.ShipCountry ORDER BY COUNT(T3.ProductID) DESC LIMIT 1 |
Write SQL query to solve given problem: What are the most popular confections product and calculate the total sales generated by this product?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(T1.UnitPrice * T3.Quantity) FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID INNER JOIN `Order Details` AS T3 ON T1.ProductID = T3.ProductID WHERE T2.CategoryName = 'Confections' GROUP BY T3.Quantity ORDER BY T3.Quantity DESC LIMIT 1 |
Write SQL query to solve given problem: What is the name of product with the ID of 77?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT ProductName FROM Products WHERE ProductID = 77 |
Write SQL query to solve given problem: State the name of employee that manages the order from Victuailles en stock?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT DISTINCT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.CompanyName = 'Victuailles en stock' |
Write SQL query to solve given problem: What is the ratio number of territories in Northern region and number territories in Western region?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT CAST(( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Northern' ) AS REAL) * 100 / ( SELECT COUNT(T1.TerritoryID) FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T2.RegionDescription = 'Westerns' ) AS Calu |
Write SQL query to solve given problem: Provide employees' ID who are in-charge of territory ID from 1000 to 2000.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT EmployeeID FROM EmployeeTerritories WHERE TerritoryID BETWEEN 1000 AND 2000 |
Write SQL query to solve given problem: Describe Sales Representative names who were hired in 1992 and compare the number of orders among them.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.FirstName, T1.LastName, COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.Title = 'Sales Representative' AND STRFTIME('%Y', T1.HireDate) = '1992' GROUP BY T1.EmployeeID, T1.FirstName, T1.LastName |
Write SQL query to solve given problem: Calculate the total payment of orders for Vegie-spread product.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) AS sum FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName = 'Vegie-spread' |
Write SQL query to solve given problem: List down the company names which supplied products for the order on 14th August, 1996.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID INNER JOIN Orders AS T4 ON T3.OrderID = T4.OrderID WHERE date(T4.OrderDate) = '1996-08-14' |
Write SQL query to solve given problem: Among the product lists in order ID 10337, write down the product names and suppliers which had the highest in reorder level.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.ProductName, T1.CompanyName FROM Suppliers AS T1 INNER JOIN Products AS T2 ON T1.SupplierID = T2.SupplierID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID WHERE T3.OrderID = 10337 ORDER BY T2.ReorderLevel DESC LIMIT 1 |
Write SQL query to solve given problem: Name the shipper which had the most shipments in first quarter of 1998.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.CompanyName FROM Shippers AS T1 INNER JOIN Orders AS T2 ON T1.ShipperID = T2.ShipVia WHERE STRFTIME('%Y', T2.ShippedDate) = '1998' GROUP BY T1.CompanyName ORDER BY COUNT(T2.OrderID) DESC LIMIT 1 |
Write SQL query to solve given problem: List out the full name of employee who has birth day on "3/4/1955 12:00:00 AM".. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT FirstName, LastName FROM Employees WHERE BirthDate = '1955-03-04 00:00:00' |
Write SQL query to solve given problem: Mention the first name of employee who took care the order id 10250.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10250 |
Write SQL query to solve given problem: What is the country location of the employee who handled order id 10257?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.Country FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10257 |
Write SQL query to solve given problem: What is the title of the employee who handled order id 10270?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.Title FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10257 |
Write SQL query to solve given problem: Give the phone number of the customer who placed the order id 10264.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.Phone FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10264 |
Write SQL query to solve given problem: What is the region where the customer who placed the order id 10276 located?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.Region FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10276 |
Write SQL query to solve given problem: Among the employees who handled orders to Brazil, who has the highest salary and calculate the average salary of them.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.FirstName, T1.LastName, AVG(T1.Salary) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.ShipCountry = 'Brazil' GROUP BY T1.FirstName, T1.LastName ORDER BY SUM(T1.Salary) DESC LIMIT 1 |
Write SQL query to solve given problem: Calculate the percentage salary of employees who handled orders shipped in 1996.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T2.ShippedDate) = '1996' THEN T1.Salary ELSE 0 END) AS REAL) * 100 / SUM(T1.Salary) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID |
Write SQL query to solve given problem: When was the employee who handled order id 10281 hired?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.HireDate FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10281 |
Write SQL query to solve given problem: How many orders was handled by employees who reported to employee id 5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.ReportsTo = 5 |
Write SQL query to solve given problem: Give the full name of employee who handled the order id 10280.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10280 |
Write SQL query to solve given problem: State the shipping company of order id 10260.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.CompanyName FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10260 |
Write SQL query to solve given problem: List out the phone number of the shipping company of order id 10296.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retail_world | SELECT T2.Phone FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T1.OrderID = 10260 |
Write SQL query to solve given problem: How many kinds of items are returned in order no.5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_orderkey = 5 AND l_returnflag = 'R' |
Write SQL query to solve given problem: When was the latest date the items of order no.1 were shipped?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT MAX(l_shipdate) FROM lineitem WHERE l_orderkey = 1 |
Write SQL query to solve given problem: Which order has a higher priority, order no. 4 or order no. 36?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT l_orderkey FROM lineitem WHERE l_orderkey IN (4, 36) ORDER BY l_shipdate DESC LIMIT 1 |
Write SQL query to solve given problem: What is the comment of the order with the highest total price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT o_comment FROM orders WHERE o_totalprice = ( SELECT MAX(o_totalprice) FROM orders ) |
Write SQL query to solve given problem: What is the phone number of Customer#000000001?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT c_phone FROM customer WHERE c_name = 'Customer#000000001' |
Write SQL query to solve given problem: How many orders in total have the customers in the household segment made?. 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 WHERE T2.c_mktsegment = 'HOUSEHOLD' |
Write SQL query to solve given problem: Among all the orders made by a customer in the household segment, what is the highest total price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT MAX(T1.o_totalprice) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' |
Write SQL query to solve given problem: Please list the order comments of all the orders made by customers in the household 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 = 'HOUSEHOLD' |
Write SQL query to solve given problem: Please give the name of the customer who has made the single order with the highest total price.. 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 ORDER BY T1.o_totalprice DESC LIMIT 1 |
Write SQL query to solve given problem: Please list the order keys of all the orders made by a customer whose account is in debt.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT T1.o_orderkey FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_acctbal < 0 |
Write SQL query to solve given problem: Among the orders made by customers in the household segment, how many of them are urgent?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(T1.o_orderpriority) FROM orders AS T1 INNER JOIN customer AS T2 ON T1.o_custkey = T2.c_custkey WHERE T2.c_mktsegment = 'HOUSEHOLD' AND T1.o_orderpriority = '1-URGENT' |
Write SQL query to solve given problem: How many customers are in Brazil?. 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' |
Write SQL query to solve given problem: Please list the phone numbers of all the customers in the household segment and are in Brazil.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT T1.c_phone FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey WHERE T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'BRAZIL' |
Write SQL query to solve given problem: Among all the customers in Germany, how many of them have an account balance of over 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 = 'GERMANY' AND T1.c_acctbal > 1000 |
Write SQL query to solve given problem: How many orders in total are made by customers in Germany?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: What is the total price of all the orders made by customers in Germany?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: Among the orders made by customers in Germany, which one of them has the highest priority in delivery? Please give its order key.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: What is the average price of the orders made by a customer in Germany?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: Among all the customers, what is the percentage of the customer's nation being 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.c_custkey) FROM customer AS T1 INNER JOIN nation AS T2 ON T1.c_nationkey = T2.n_nationkey |
Write SQL query to solve given problem: How many countries are there in the No.2 region?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(n_nationkey) FROM nation WHERE n_regionkey = 2 |
Write SQL query to solve given problem: Which country does supplier No.34 come from?. 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 = 34 |
Write SQL query to solve given problem: Which region does "Supplier#000000129" belong to?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: What is the nationality of "Customer#000000055"?. 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_name = 'Customer#000000055' |
Write SQL query to solve given problem: Give customer No.106936's region name.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: Give the number of Moroccan customers whose account is in debt.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: For the order with the total price of 231499.38, what was the discounted price for supplier No. 9397?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: For the order with the total price of 218195.43, which supplier handled the returned item? Give the supplier id.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: Customer No.129301 made an order on 1996/7/27, what was the delivery time for the first part of that order?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: Give the name of the customer who made an order with Clerk#000000803 on 1997/12/10.. 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_orderdate = '1997-12-10' AND T1.o_clerk = 'Clerk#000000803' |
Write SQL query to solve given problem: Calculates the profit processed by Supplier No. 7414 on order No. 817154.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: Which country has the most number of suppliers whose account is in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: What is the percentage of the European countries among the given countries?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT CAST(SUM(IIF(T2.r_name = 'EUROPE', 1, 0)) AS REAL) * 100 / COUNT(T1.n_name) FROM nation AS T1 INNER JOIN region AS T2 ON T1.n_regionkey = T2.r_regionkey |
Write SQL query to solve given problem: Give the percentage of Japanese suppliers whose account is in debt.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT CAST(SUM(IIF(T2.n_name = 'JAPAN', 1, 0)) AS REAL) * 100 / 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 |
Write SQL query to solve given problem: What is the name of the customer with the highest amount of 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: How many orders were shipped in 1998?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(l_orderkey) FROM lineitem WHERE STRFTIME('%Y', l_shipdate) = '1998' |
Write SQL query to solve given problem: How many customers are in debt?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(c_custkey) FROM customer WHERE c_acctbal < 0 |
Write SQL query to solve given problem: How many items that were shipped via air were returned in 1994?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(l_linenumber) FROM lineitem WHERE l_returnflag = 'R' AND l_shipmode = 'AIR' AND STRFTIME('%Y', l_shipdate) = '1994' |
Write SQL query to solve given problem: How many customers are in the automobile market segment?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT COUNT(c_custkey) FROM customer WHERE c_mktsegment = 'AUTOMOBILE' |
Write SQL query to solve given problem: What are the top 2 order keys of the item with the highest amount of extended price?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | SELECT l_orderkey FROM lineitem ORDER BY l_extendedprice DESC LIMIT 2 |
Write SQL query to solve given problem: When was the order with the highest amount of total price shipped?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: In which country do most of the customers come from?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: How many urgent orders were shipped the next day?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Write SQL query to solve given problem: How many in debt customers in the household market segment are from Russia?. 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 T1.c_mktsegment = 'HOUSEHOLD' AND T2.n_name = 'RUSSIA' |
Write SQL query to solve given problem: How many suppliers are from Japan?. 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 = 'JAPAN' |
Write SQL query to solve given problem: How many orders shipped via ship have a medium priority?. 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 = 'SHIP' AND T1.o_orderpriority = '3-MEDIUM' |
Write SQL query to solve given problem: Among the customers from the United States, which market segment has the highest number of customers?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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 |
Write SQL query to solve given problem: What are the countries in the region of 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: What are the names of the parts manufactured by manufacturer 3 that have a supply cost of 1,000?. 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 WHERE T1.ps_supplycost = 1000 AND T2.p_mfgr = 'Manufacturer#3' |
Write SQL query to solve given problem: How many countries are there in the region whose comment description is "asymptotes sublate after the r.". 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 WHERE T2.r_comment = 'asymptotes sublate after the r' |
Write SQL query to solve given problem: 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?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | retails | 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' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.