problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: Which employee handled the most amount of orders in 1996? Give the full name, title, and address of this employee.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT FirstName, LastName, Title, address FROM Employees WHERE EmployeeID = ( SELECT T1.EmployeeID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderDate BETWEEN '1996-01-01 00:00:00' AND '1997-01-01 00:00:00' GROUP BY T1.EmployeeID ORDER BY COUNT(T2.OrderID) DESC LIMIT 1 )
Write SQL query to solve given problem: What was the average unit price of products shipped via United Package in 1997?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT AVG(T2.UnitPrice) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Shippers AS T3 ON T1.ShipVia = T3.ShipperID WHERE T1.OrderDate LIKE '1997%' AND T3.CompanyName = 'United Package'
Write SQL query to solve given problem: Calculate the percentage of shipping done through Speedy Express.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T2.CompanyName = 'Speedy Express' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.ShipVia) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID
Write SQL query to solve given problem: Indicate the courtesy title of the 3 employees who have the lowest salary.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT TitleOfCourtesy FROM Employees ORDER BY Salary LIMIT 3
Write SQL query to solve given problem: What is the highest total price paid for an order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT UnitPrice * Quantity * (1 - Discount) AS THETOP FROM `Order Details` ORDER BY UnitPrice * Quantity * (1 - Discount) DESC LIMIT 1
Write SQL query to solve given problem: Which 3 products are produced in greater quantity?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT ProductName FROM Products ORDER BY UnitsInStock + UnitsOnOrder DESC LIMIT 3
Write SQL query to solve given problem: Of the 10 products with the highest unit price, identify by their ID the ones that have generated the least satisfaction.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT ProductID FROM Products ORDER BY ReorderLevel ASC, UnitPrice DESC LIMIT 1
Write SQL query to solve given problem: How many non-discontinued products are there in the dairy category?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T1.CategoryID) FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.CategoryName = 'Dairy Products' AND T2.Discontinued = 0
Write SQL query to solve given problem: Indicate the name of the companies that have freighted products for a value greater than 2,000,000.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.Freight > 2000000
Write SQL query to solve given problem: Through which companies have products been shipped the most times to the city of Aachen?. 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.ShipCity = 'Aachen' GROUP BY T2.CompanyName ORDER BY COUNT(T1.ShipVia) DESC LIMIT 1
Write SQL query to solve given problem: What product is the least shipped to the postal code 28023?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T4.ProductName 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 INNER JOIN Products AS T4 ON T3.ProductID = T4.ProductID WHERE T1.PostalCode = 28023 ORDER BY T3.Quantity LIMIT 1
Write SQL query to solve given problem: On what date did the Du monde entier company request that 9 units of Filo Mix be sent to it?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.OrderDate 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 INNER JOIN Products AS T4 ON T3.ProductID = T4.ProductID WHERE T4.ProductName = 'Filo Mix' AND T3.Quantity = 9 AND T1.CompanyName = 'Du monde entier'
Write SQL query to solve given problem: Indicate the name of the categories to which the products of order number 10933 belong.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T3.CategoryName FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Categories AS T3 ON T1.CategoryID = T3.CategoryID WHERE T2.OrderID = 10933
Write SQL query to solve given problem: What is the average quantity of product that have been shipped by Federal Shipping in November 1996?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(SUM(T2.Quantity) AS REAL) / COUNT(T2.OrderID) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Shippers AS T3 ON T1.ShipVia = T3.ShipperID WHERE T1.ShippedDate LIKE '1996-11%' AND T3.CompanyName = 'Federal Shipping'
Write SQL query to solve given problem: Of all the shipments made by United Package throughout the year 1996, what percentage correspond to the month of September?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T1.ShippedDate LIKE '1996-09%' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.ShipVia) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'United Package' AND T1.ShippedDate LIKE '1996%'
Write SQL query to solve given problem: What are the companies that have the same phone area code as 171?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CompanyName FROM Customers WHERE Phone LIKE '(171)%'
Write SQL query to solve given problem: What is the family name of the employee who shipped the order 10521 to CACTU?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.LastName FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.OrderID = 10521 AND T2.CustomerID = 'CACTU'
Write SQL query to solve given problem: What is the shipping cost for order number 10692 from the company Alfreds Futterkiste?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.Freight FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10692 AND T1.CompanyName = 'Alfreds Futterkiste'
Write SQL query to solve given problem: What is the shipping company for order number 10558?. 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 = 10558
Write SQL query to solve given problem: Please list any three order numbers that have been shipped using Speedy Express.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.OrderID FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Speedy Express' LIMIT 3
Write SQL query to solve given problem: What is the description of the category that tofu belongs to?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.Description FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.ProductName = 'tofu'
Write SQL query to solve given problem: What are the products that are supplied by Aux joyeux ecclsiastiques?. 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 = 'Aux joyeux ecclsiastiques'
Write SQL query to solve given problem: Please name any three products that have been discontinued in the meat or poultry category.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.ProductName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID WHERE T2.Discontinued = 1 AND T1.CategoryName = 'Meat/Poultry' LIMIT 3
Write SQL query to solve given problem: Please name any two products that have the highest satisfaction levels among users of Heli Swaren GmbH & Co. KG.. 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 = 'Heli Swaren GmbH & Co. KG' ORDER BY T1.ReorderLevel DESC LIMIT 2
Write SQL query to solve given problem: What is the largest total price for an order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(UnitPrice) FROM `Order Details` GROUP BY OrderID ORDER BY SUM(UnitPrice) DESC LIMIT 1
Write SQL query to solve given problem: What is the largest quantity of "Manjimup Dried Apples" for an order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.Quantity FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T2.ProductID = T1.ProductID WHERE T1.ProductName = 'Manjimup Dried Apples' ORDER BY T2.Quantity DESC LIMIT 1
Write SQL query to solve given problem: List all the products that were shipped to Starenweg 5.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T3.ProductName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.ShipAddress = 'Starenweg 5' GROUP BY T3.ProductName
Write SQL query to solve given problem: What proportion of orders are taken by the Sales Representative?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T1.Title = 'Sales Representative' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID
Write SQL query to solve given problem: What is the average salary for employees from ID 1 to 9?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT AVG(Salary) FROM Employees WHERE EmployeeID BETWEEN 1 AND 9
Write SQL query to solve given problem: Is (206) 555-1189 the home phone number for Laura Callahan?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CASE WHEN HomePhone = '(206) 555-1189' THEN 'YES' ELSE 'NO' END FROM Employees WHERE FirstName = 'Laura' AND LastName = 'Callahan'
Write SQL query to solve given problem: Please calculate the average unit price for products of Formaggi Fortini s.r.l.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T1.UnitPrice) / COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.CompanyName = 'Formaggi Fortini s.r.l.'
Write SQL query to solve given problem: What is the contact title for the person who supplied a product that is 10 boxes x 12 pieces.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.ContactTitle FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.QuantityPerUnit = '10 boxes x 12 pieces'
Write SQL query to solve given problem: Calculate the percentage of products supplied by Gai pturage over all products.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T2.CompanyName = 'Gai pturage' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.SupplierID) FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID
Write SQL query to solve given problem: List the product ID of the top five products, by descending order, the number of quantities in stock.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT ProductID FROM Products ORDER BY UnitsInStock DESC LIMIT 5
Write SQL query to solve given problem: Among the products, how many of them were discontinued in production?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(*) FROM Products WHERE Discontinued = 1
Write SQL query to solve given problem: Write down the top ten companies with the most total sales by amount.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CompanyName FROM `Sales Totals by Amount` ORDER BY SaleAmount DESC LIMIT 10
Write SQL query to solve given problem: What is the average sales for each categories?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT AVG(ProductSales) FROM `Sales by Category` GROUP BY CategoryName
Write SQL query to solve given problem: Compute the total order quantity for Uncle Bob's Organic Dried Pears so far.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T2.Quantity) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductName LIKE 'Uncle Bob%s Organic Dried Pears'
Write SQL query to solve given problem: Among the seafoods, how many of them have an order quantity of more than 50?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Categories AS T3 ON T1.CategoryID = T3.CategoryID WHERE T3.CategoryName = 'Seafood' AND T2.Quantity > 50
Write SQL query to solve given problem: Who are the suppliers of the discontinued products?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT DISTINCT T2.CompanyName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.Discontinued = 1
Write SQL query to solve given problem: Among the employees, give me the full names of those who have less than 4 territories.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.FirstName, T1.LastName FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T2.EmployeeID < 4
Write SQL query to solve given problem: From 1/3/97 to 8/10/97, 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.ShippedDate BETWEEN '1997-03-01 00:00:00' AND '1997-10-08 23:59:59'
Write SQL query to solve given problem: Tally the customer ID of orders that were shipped to Brazil by Margaret Peacock from 3/31/97 to 12/10/97.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT DISTINCT T2.CustomerID FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.LastName = 'Peacock' AND T1.FirstName = 'Margaret' AND T2.ShipCountry = 'Brazil' AND T2.ShippedDate BETWEEN '1997-03-31 00:00:00' AND '1997-12-10 23:59:59'
Write SQL query to solve given problem: What is the re-order level of products that have an order quantity of 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.ReorderLevel FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity = 1
Write SQL query to solve given problem: Which of the American customers have experienced a delay in the shipment and how long was the longest?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName, TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.Country = 'USA' AND TIMESTAMPDIFF(DAY, T2.ShippedDate, T2.RequiredDate) < 0
Write SQL query to solve given problem: What is the contact name and phone number of the customer who has made the most total payment on the order to date?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.ContactName, T1.Phone 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 T2.OrderID, T1.ContactName, T1.Phone ORDER BY SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) DESC LIMIT 1
Write SQL query to solve given problem: Who is the sales representative of the customer who has made the highest payment? Include the full name of employee and his/her supervisor.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T4.LastName, T4.FirstName, T4.ReportsTo , T1.Quantity * T1.UnitPrice * (1 - T1.Discount) AS payment FROM `Order Details` AS T1 INNER JOIN Orders AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID INNER JOIN Employees AS T4 ON T2.EmployeeID = T4.EmployeeID ORDER BY payment DESC LIMIT 1
Write SQL query to solve given problem: Which region has the most territories?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.RegionID FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID GROUP BY T2.RegionID ORDER BY COUNT(T1.TerritoryID) DESC LIMIT 1
Write SQL query to solve given problem: Which region does territory id 2116 belong to?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.RegionDescription FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID WHERE T1.TerritoryID = 2116
Write SQL query to solve given problem: What percentage of orders were placed by customers in Madrid city in 1996?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T1.City = 'Madrid' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.City) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = 1996
Write SQL query to solve given problem: How many sales representatives whose salaries are higher than 2000?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(Title) FROM Employees WHERE Salary > 2000 AND Title = 'Sales Representative'
Write SQL query to solve given problem: In 1996, how many orders were from customers in the UK?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T1.CustomerID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1996' AND T1.Country = 'UK'
Write SQL query to solve given problem: Which company had the most orders in 1998?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1998' GROUP BY T1.CompanyName ORDER BY COUNT(T2.OrderID) DESC LIMIT 1
Write SQL query to solve given problem: Please calculate the number of orders from customers by country in 1996.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T2.CustomerID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1996' GROUP BY T1.Country
Write SQL query to solve given problem: How many orders were from Hanna Moos company in 1999?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T2.OrderID) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE STRFTIME('%Y', T2.OrderDate) = '1999' AND T1.CompanyName = 'Hanna Moos'
Write SQL query to solve given problem: How many days was the fastest shipping of Berglunds snabbkp's order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT datediff(T2.ShippedDate, T2.OrderDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.CompanyName = 'Berglunds snabbkp' ORDER BY datediff(T2.ShippedDate, T2.OrderDate) LIMIT 1
Write SQL query to solve given problem: Which company placed the order with the id 10257?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T2.OrderID = 10257
Write SQL query to solve given problem: In which year did Around the Horn place the most orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT STRFTIME('%Y', T2.OrderDate) FROM Customers AS T1 INNER JOIN Orders AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.CompanyName = 'Around the Horn' GROUP BY STRFTIME('%Y', T2.OrderDate) ORDER BY COUNT(T2.OrderID) DESC LIMIT 1
Write SQL query to solve given problem: Which country are the majority of the suppliers located?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT Country FROM Suppliers GROUP BY Country ORDER BY COUNT(SupplierID) DESC LIMIT 1
Write SQL query to solve given problem: In August of 1996, how many orders were placed by the customer with the highest amount of orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(OrderID) FROM Orders WHERE OrderDate LIKE '1996-08%' GROUP BY CustomerID ORDER BY COUNT(OrderID) DESC LIMIT 1
Write SQL query to solve given problem: What is the total sales amount of all discontinued products?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T2.UnitPrice * T2.Quantity) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Discontinued = 1
Write SQL query to solve given problem: What is the category of the product that has the highest number of discontinued products?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.CategoryName FROM Products AS T1 INNER JOIN Categories AS T2 ON T1.CategoryID = T2.CategoryID WHERE T1.Discontinued = 1 GROUP BY T2.CategoryName ORDER BY COUNT(T1.ProductID) DESC LIMIT 1
Write SQL query to solve given problem: How many condiments were sold in 1997?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T2.ProductID) FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID INNER JOIN `Order Details` AS T3 ON T2.ProductID = T3.ProductID INNER JOIN Orders AS T4 ON T3.OrderID = T4.OrderID WHERE T1.CategoryName = 'Condiments' AND T1.CategoryID = 2 AND T4.OrderDate LIKE '1997%'
Write SQL query to solve given problem: Who is the customer who purchased the highest number of products in a single order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName 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 ORDER BY COUNT(T3.ProductID) DESC LIMIT 1
Write SQL query to solve given problem: What is the monthly average number of products shipped via Federal Shipping for the year 1996?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(SUM(T1.ShipVia) AS REAL) / 12 FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Federal Shipping' AND T1.ShippedDate LIKE '1996%'
Write SQL query to solve given problem: Which products are being supplied by "G'day, Mate"? List all of their names.. 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 'G%day, Mate'
Write SQL query to solve given problem: How many territories are there in the region with the highest number of territories?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T2.RegionDescription), T1.TerritoryDescription, COUNT(*) AS num FROM Territories AS T1 INNER JOIN Region AS T2 ON T1.RegionID = T2.RegionID GROUP BY T1.TerritoryDescription ORDER BY num DESC LIMIT 1
Write SQL query to solve given problem: How many female employees are in charge of 3 or more territories?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(EID) FROM ( SELECT T1.EmployeeID AS EID FROM Employees AS T1 INNER JOIN EmployeeTerritories AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.TitleOfCourtesy IN ('Ms.' OR 'Mrs.') GROUP BY T1.EmployeeID HAVING COUNT(T2.TerritoryID) >= 3 ) T1
Write SQL query to solve given problem: Who are the top 8 suppliers supplying the products with the highest user satisfaction?. 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 ORDER BY T1.ReorderLevel DESC LIMIT 8
Write SQL query to solve given problem: What is the company name of the customer who made the biggest amount of purchase in a single order before discount?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName 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 WHERE T3.Discount = 0 GROUP BY T1.CompanyName ORDER BY SUM(T3.UnitPrice * T3.Quantity) DESC LIMIT 1
Write SQL query to solve given problem: What was the total amount of sales handled by Nancy Davolio in December 1996, excluding discounts?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T3.UnitPrice * T3.Quantity) 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.FirstName = 'Nancy' AND T1.LastName = 'Davolio' AND T2.OrderDate LIKE '1996-12%' AND T3.Discount = 0
Write SQL query to solve given problem: What is the total amount of sales made in the year 1997?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID WHERE T1.OrderDate LIKE '1997%'
Write SQL query to solve given problem: What is the average annual amount of shipped sales from 1997 to 1998?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) / 3 FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID WHERE T1.ShippedDate BETWEEN '1996-01-01 00:00:00' AND '1998-12-31 23:59:59'
Write SQL query to solve given problem: How many orders were shipped to Venezuela in 1996?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(OrderID) FROM Orders WHERE ShipCountry = 'Venezuela' AND STRFTIME('%Y', ShippedDate) = '1996'
Write SQL query to solve given problem: List the order IDs, product IDs and unit price of orders which total payment is greater than 15000.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT ProductID, OrderID, UnitPrice FROM `Order Details` WHERE UnitPrice * Quantity * (1 - Discount) > 15000
Write SQL query to solve given problem: Provide the territory IDs under employee ID of 7.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT TerritoryID FROM EmployeeTerritories WHERE EmployeeID = 7
Write SQL query to solve given problem: List the employees' full names and ages in 2022 who lived in London.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT TitleOfCourtesy, FirstName, LastName , TIMESTAMPDIFF(YEAR, BirthDate, NOW()) AS ages FROM Employees WHERE City = 'London'
Write SQL query to solve given problem: Find the total production amount and product names which had "10 - 500 g pkgs." as quantity per unit.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT UnitsInStock + UnitsOnOrder, ProductName FROM Products WHERE QuantityPerUnit = '10 - 500 g pkgs.'
Write SQL query to solve given problem: List all the product names and categories of the highest reorder level.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.ProductName, T1.CategoryName FROM Categories AS T1 INNER JOIN Products AS T2 ON T1.CategoryID = T2.CategoryID ORDER BY T2.ReorderLevel DESC LIMIT 1
Write SQL query to solve given problem: Describe the supplier companies, cities and products which total production amount is more than 120.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.CompanyName, T2.City, T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T1.UnitsInStock + UnitsOnOrder > 120
Write SQL query to solve given problem: What products were ordered by the customer ID "WILMK" which were required on 3/26/1998?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T3.ProductName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.RequiredDate LIKE '1998-03-26%' AND T1.CustomerID = 'WILMK'
Write SQL query to solve given problem: Provide the products list which were ordered in 1996 by the company in Norway.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T4.ProductName 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 INNER JOIN Products AS T4 ON T3.ProductID = T4.ProductID WHERE T1.Country = 'Norway' AND STRFTIME('%Y', T2.OrderDate) = '1996'
Write SQL query to solve given problem: Among orders shipping to Brazil, mention the supplier company of the order which was done by employee Anne Dodsworth in December, 1996 .. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T5.CompanyName 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 INNER JOIN Products AS T4 ON T3.ProductID = T4.ProductID INNER JOIN Suppliers AS T5 ON T4.SupplierID = T5.SupplierID WHERE T1.FirstName = 'Anne' AND T1.LastName = 'Dodsworth' AND T2.ShipCountry = 'Brazil' AND T2.OrderDate LIKE '1996-12%'
Write SQL query to solve given problem: Mention the oldest empoyee's full name, title, salary and number of orders which were shipped to USA by him.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.FirstName, T1.LastName, T1.Title, T1.Salary , COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE ShipCountry = 'USA' GROUP BY T1.FirstName, T1.LastName, T1.Title, T1.Salary, T1.BirthDate ORDER BY T1.BirthDate LIMIT 1
Write SQL query to solve given problem: Calculate the average payment per product under confections category.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) / COUNT(T1.ProductID) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Categories AS T3 ON T1.CategoryID = T3.CategoryID WHERE T3.CategoryName = 'Confections'
Write SQL query to solve given problem: Find the total payment of the orders by customers from San Francisco.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) AS TOTALPAYMENT 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 WHERE T1.City = 'San Francisco'
Write SQL query to solve given problem: Among the supplied products from Australia, describe the discontinued products and the category.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.ProductName, 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.Country = 'Australia' AND T2.Discontinued = 1
Write SQL query to solve given problem: Mention the supplier country of Ipoh Coffee and the order ID which had maximum in total payment.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T3.Country, T1.OrderID FROM `Order Details` AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Suppliers AS T3 ON T2.SupplierID = T3.SupplierID WHERE T2.ProductName = 'Ipoh Coffee' ORDER BY T1.UnitPrice * T1.Quantity * (1 - T1.Discount) DESC LIMIT 1
Write SQL query to solve given problem: Provide the list of products ordered by ID 10979 and calculate its total payment.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.ProductName , SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10979 GROUP BY T1.ProductName
Write SQL query to solve given problem: Among the products under grains/cereals category, provide the contact person and title of the supplier with one digit ID.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT DISTINCT T1.ContactName, T1.ContactTitle 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 T3.CategoryName = 'Grains/Cereals' AND T1.SupplierID BETWEEN 1 AND 10 LIMIT 1
Write SQL query to solve given problem: Provide Speedy Express's phone number and number of shipped orders on 30th January, 1998.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T2.Phone, COUNT(T1.OrderID) FROM Orders AS T1 INNER JOIN Shippers AS T2 ON T1.ShipVia = T2.ShipperID WHERE T2.CompanyName = 'Speedy Express' AND T1.ShippedDate LIKE '1998-01-30%' GROUP BY T2.Phone
Write SQL query to solve given problem: Describe the ordered products which were the most overdue from required date.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT DISTINCT T3.ProductName FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE DATEDIFF(T1.ShippedDate, T1.RequiredDate) < 0
Write SQL query to solve given problem: Under the in-charge of inside sales coordinator, provide the product lists which were shipped to Mexico in 1996.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T4.ProductName 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 INNER JOIN Products AS T4 ON T3.ProductID = T4.ProductID WHERE T1.Title = 'Inside Sales Coordinator' AND T2.ShippedDate LIKE '1996%' AND T2.ShipCountry = 'Mexico'
Write SQL query to solve given problem: Identify the customer, which placed the largest order in terms of value.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT T1.CompanyName 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 T2.CustomerID ORDER BY SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) DESC LIMIT 1
Write SQL query to solve given problem: What is the average value of the sales order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT SUM(UnitPrice * Quantity * (1 - Discount)) / COUNT(OrderID) FROM `Order Details`
Write SQL query to solve given problem: Find the percentage of discontinued products in Northwind's portfolio of products.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN Discontinued = 1 THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(ProductID) FROM Products
Write SQL query to solve given problem: Provide the full name of the employee who processed the sales order with ID 10274.. 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 = 10274
Write SQL query to solve given problem: Identify the total number of orders placed by the customer 'Laughing Bacchus Wine Cellars' and it's average value.. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT COUNT(T2.OrderID) , SUM(T3.UnitPrice * T3.Quantity * (1 - T3.Discount)) / COUNT(T2.OrderID) 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 WHERE T1.CompanyName = 'Laughing Bacchus Wine Cellars'
Write SQL query to solve given problem: What products are no longer sold by Northwind?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT ProductName FROM Products WHERE Discontinued = 1
Write SQL query to solve given problem: Identify the total number of orders processed by Northwind employee named Andrew Fuller. What percent of those orders was shipped to Austria?. Keep the solution inside sql tag ```sql [SQL-Query] ```
retail_world
SELECT CAST(COUNT(CASE WHEN T2.ShipCountry = 'Austria' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.OrderID) FROM Employees AS T1 INNER JOIN Orders AS T2 ON T1.EmployeeID = T2.EmployeeID WHERE T1.FirstName = 'Andrew' AND T1.LastName = 'Fuller'