problem
stringlengths 121
422
| db_id
stringclasses 69
values | solution
stringlengths 23
804
|
---|---|---|
Write SQL query to solve given problem: Please list the names of the products that have over 3 price changes.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductListPriceHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Name ORDER BY COUNT(T1.ListPrice) > 3 |
Write SQL query to solve given problem: What is the highest vendor's selling price for Hex Nut 5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice DESC LIMIT 1 |
Write SQL query to solve given problem: Please list all the vendors' usual selling prices of the product Hex Nut 5.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' GROUP BY T1.StandardPrice ORDER BY COUNT(T1.StandardPrice) DESC LIMIT 1 |
Write SQL query to solve given problem: Among the vendors that sell the product Hex Nut 5, how many of them have a good credit rating?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(DISTINCT T3.Name) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5' AND T3.CreditRating = 1 AND 3 |
Write SQL query to solve given problem: Please list the website purchasing links of the vendors from whom the product Hex Nut 5 can be purchased.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.PurchasingWebServiceURL FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5' |
Write SQL query to solve given problem: Which vendor's selling price for Hex Nut 5 is the lowest, please give the vendor's name.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Name = 'Hex Nut 5' ORDER BY T1.StandardPrice LIMIT 1 |
Write SQL query to solve given problem: How many high-class products are sold by preferred vendors?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T2.Name) FROM ProductVendor AS T1 INNER JOIN Product AS T2 USING (ProductID) INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.PreferredVendorStatus = 1 AND T2.Class = 'M' |
Write SQL query to solve given problem: Among the products from the mountain product line, how many of them are sold by over 2 vendors?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(CASE WHEN T1.ProductLine = 'M' THEN 1 ELSE 0 END) FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID GROUP BY T1.ProductID HAVING COUNT(T1.Name) > 2 |
Write SQL query to solve given problem: Among the products that get over at least 1 review, how many of them are from the mountain product line?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(CASE WHEN T2.ProductLine = 'M' THEN 1 ELSE 0 END) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID HAVING COUNT(T1.ProductReviewID) > 1 |
Write SQL query to solve given problem: Please list the email adresses of the reviewers who have given the lowest rating to the product HL Mountain Pedal.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'HL Mountain Pedal' ORDER BY T1.Rating LIMIT 1 |
Write SQL query to solve given problem: How many products that take more than 2 days to make are out of stock?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T2.ProductID) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.OnOrderQty IS NULL OR T1.OnOrderQty = 0 |
Write SQL query to solve given problem: Please list the products that are out of stock and purchased in house.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 0 AND (T1.OnOrderQty IS NULL OR T1.OnOrderQty = 0) |
Write SQL query to solve given problem: Among the salable products from the mountain product line, how many of them have the most reviews?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(CASE WHEN T2.ProductLine = 'M' THEN 1 ELSE 0 END) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T1.ProductID ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1 |
Write SQL query to solve given problem: What is the average selling price of different vendors of the product Hex Nut 5?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(T1.StandardPrice) / COUNT(T1.BusinessEntityID) FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Hex Nut 5' |
Write SQL query to solve given problem: What is the product that has the highest average rating from the mountain product line?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ProductLine = 'M' GROUP BY T2.Name ORDER BY CAST(SUM(T1.Rating) AS REAL) / COUNT(T1.ProductID) DESC LIMIT 1 |
Write SQL query to solve given problem: Please list the top 3 house-manufactured products with the highest average rating.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY SUM(T1.Rating) DESC LIMIT 1 |
Write SQL query to solve given problem: Name all salaried employee who are hired in 2007 and later.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.HireDate) >= '2007' AND T2.SalariedFlag = 1 |
Write SQL query to solve given problem: List the name of married employees with less than 20 vacation hours.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T2.VacationHours < 20 |
Write SQL query to solve given problem: Name the oldest employee who is working on night shift. How old is the employee?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName , STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.ShiftId = 3 ORDER BY STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) DESC LIMIT 1 |
Write SQL query to solve given problem: List all staff in the Shipping and Receiving department who are hired in 2009.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID WHERE STRFTIME('%Y', T2.HireDate) = '2009' AND T4.Name = 'Shipping and Receiving' |
Write SQL query to solve given problem: What is the job title of the oldest employee in the company? In which department is he in?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.JobTitle, T4.Name FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID ORDER BY T2.HireDate LIMIT 1 |
Write SQL query to solve given problem: Other than the Chief Executive Officer, who is the employee who has the highest payrate? State the rate.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.LastName FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle NOT LIKE 'Chief Executive Officer' ORDER BY T1.Rate DESC LIMIT 1 |
Write SQL query to solve given problem: Name the vendor who has the shortest average lead time for Product ID 319.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 319 ORDER BY T2.AverageLeadTime LIMIT 1 |
Write SQL query to solve given problem: Which vendor gives the best profit on net for product ID 342?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 342 ORDER BY T2.LastReceiptCost - T2.StandardPrice DESC LIMIT 1 |
Write SQL query to solve given problem: What is the current payrate of Rob Walters? Calculate the percentage increment from his previous payrate.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Rate , (MAX(T2.Rate) - MIN(T2.Rate)) * 100 / MAX(T2.Rate) FROM Person AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'Rob' AND T1.LastName = 'Walters' |
Write SQL query to solve given problem: Calculate the average length of employment for employee working in the Research and Development deparment.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT AVG(STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.HireDate)) FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Research and Development' |
Write SQL query to solve given problem: Among the employees in Adventure Works, calculate the percentage of them working as sales representatives.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CAST(SUM(CASE WHEN JobTitle = 'Sales Representative' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee |
Write SQL query to solve given problem: Name all products that started selling in 2013. State its respective vendor's name.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name, T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE STRFTIME('%Y', T1.SellStartDate) = '2013' |
Write SQL query to solve given problem: Names the Sales Representative with the highest year to date sales.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.SalesYTD DESC LIMIT 1 |
Write SQL query to solve given problem: List all product only MOQ of 1,000 and with standard cost more than 17.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaxOrderQty = 1000 AND T2.StandardCost > 17 |
Write SQL query to solve given problem: Who is the oldest married male? State his job title.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate LIMIT 1 |
Write SQL query to solve given problem: Find the vendor with the least average lead time for Product ID 348.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ProductID = 348 ORDER BY T1.AverageLeadTime ASC LIMIT 1 |
Write SQL query to solve given problem: State the employee who are born in or after 1970 and with the least sick leave hour.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.BirthDate) > '1970' ORDER BY T1.SickLeaveHours LIMIT 1 |
Write SQL query to solve given problem: Calculate the average age of employee in each department and state which department has the youngest employees.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY T1.BirthDate DESC LIMIT 1 |
Write SQL query to solve given problem: Please provide the IDs of any three AdventureWorks product subcategories.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT DISTINCT ProductCategoryID FROM ProductSubcategory LIMIT 3 |
Write SQL query to solve given problem: What are the differences between the 288th salesperson's predicted annual sales and his or her actual sales thus far?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SalesYTD - SalesQuota FROM SalesPerson WHERE BusinessEntityID = 288 |
Write SQL query to solve given problem: Please list three businesses with the lowest total sales from last year.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesLastYear LIMIT 3 |
Write SQL query to solve given problem: Which three sales regions have generated the most revenue thus far?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT TerritoryID FROM SalesTerritory ORDER BY SalesYTD DESC LIMIT 3 |
Write SQL query to solve given problem: What is the highest possible discount rate for 'Excess Inventory'?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT DiscountPct FROM SpecialOffer WHERE Type = 'Excess Inventory' ORDER BY DiscountPct DESC LIMIT 1 |
Write SQL query to solve given problem: What is the difference between the actual manufacturing cost of product number 818 and the estimated manufacturing cost?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT PlannedCost - ActualCost FROM WorkOrderRouting WHERE ProductID = 818 |
Write SQL query to solve given problem: How many materials still need to be assembled and have a depth of 2 between each component and their parent product?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(*) FROM BillOfMaterials WHERE BOMLevel = 2 AND EndDate IS NULL |
Write SQL query to solve given problem: How many of the approved documents are confidential?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(DocumentNode) FROM Document WHERE Status = 2 AND DocumentSummary IS NULL |
Write SQL query to solve given problem: Which work order transaction number has the highest product quantity?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT TransactionID FROM TransactionHistory WHERE TransactionType = 'W' ORDER BY Quantity DESC LIMIT 1 |
Write SQL query to solve given problem: Please list any 3 vendors that are not recommended by Adventure Works.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Name FROM Vendor WHERE PreferredVendorStatus = 0 LIMIT 3 |
Write SQL query to solve given problem: How many vendors does Adventure Works still work with but are not preferable?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(BusinessEntityID) FROM Vendor WHERE PreferredVendorStatus = 0 AND ActiveFlag = 1 |
Write SQL query to solve given problem: How many employees who began working in 2009 or later had night shifts?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId WHERE T2.ShiftId = 3 AND STRFTIME('%Y', T2.StartTime) >= '2009' |
Write SQL query to solve given problem: Which department, altogether, has the most personnel who work the evening shift?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.Name FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId INNER JOIN Department AS T3 ON T1.DepartmentID = T3.DepartmentID WHERE T2.Name = 'Night' GROUP BY T3.Name ORDER BY COUNT(T1.BusinessEntityID) DESC LIMIT 1 |
Write SQL query to solve given problem: What are the sales reasons for order 43718?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM SalesOrderHeaderSalesReason AS T1 INNER JOIN SalesReason AS T2 ON T1.SalesReasonID = T2.SalesReasonID WHERE T1.SalesOrderID = 43718 |
Write SQL query to solve given problem: What bike subcategories are there?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN ProductCategory AS T2 ON T1.ProductCategoryID = T2.ProductCategoryID WHERE T2.name = 'Bikes' |
Write SQL query to solve given problem: Which sales areas are expected to have the highest yearly sales quota?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID GROUP BY T1.TerritoryID ORDER BY SUM(T1.SalesQuota) DESC LIMIT 1 |
Write SQL query to solve given problem: What goods were sold to customers in accordance with sales order number 43660?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660 |
Write SQL query to solve given problem: Please list the top 5 products with the most orders.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC LIMIT 0, 5 |
Write SQL query to solve given problem: Which address type does "Fun Toys and Bikes" fall under?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID INNER JOIN Store AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.Name = 'Fun Toys and Bikes' |
Write SQL query to solve given problem: What is the 12th business's first line address?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12 |
Write SQL query to solve given problem: Please list any three businesses with their IDs that are located in Dallas City.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.BusinessEntityID FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T1.City = 'Dallas' LIMIT 3 |
Write SQL query to solve given problem: What is the difference in percentage between the product descriptions written in Arabic and Thai?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CAST(SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID |
Write SQL query to solve given problem: What percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CAST(SUM(CASE WHEN T1.SalesQuota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T2.CountryRegionCode = 'US' AND T2.Name = 'Northwest' |
Write SQL query to solve given problem: What is the name of the product with the almost highest review score?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 ) |
Write SQL query to solve given problem: What is the company's second highest salary per hour for employees who are paid monthly?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Rate FROM EmployeePayHistory WHERE PayFrequency = 1 ORDER BY Rate DESC LIMIT 1, 1 |
Write SQL query to solve given problem: How many Vista cards expired before the year 2007?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(CreditCardID) FROM CreditCard WHERE CardType = 'Vista' AND ExpYear < 2007 |
Write SQL query to solve given problem: What is the weight in pounds of the style that is produced the most by the company? If there are multiple products sharing the same weight, indicate the name of each one of them and their corresponding weights.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Weight FROM Product WHERE WeightUnitMeasureCode = 'LB' GROUP BY Weight ORDER BY COUNT(Style) DESC LIMIT 1 |
Write SQL query to solve given problem: Which territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SalesLastYear - SalesYTD, Name, CountryRegionCode FROM SalesTerritory ORDER BY SalesLastYear - SalesYTD DESC LIMIT 1 |
Write SQL query to solve given problem: What are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Name, ReorderPoint FROM Product WHERE SizeUnitMeasureCode = 'CM' ORDER BY Size DESC LIMIT 6 |
Write SQL query to solve given problem: How much is the amount to be paid by the company for the purchase order with the third highest freight amount?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 1 |
Write SQL query to solve given problem: What profit will the company gain if they sell 10 items of the product that has the lightest weight?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT 10 * (ListPrice - StandardCost) FROM Product WHERE Weight IS NOT NULL ORDER BY Weight LIMIT 1 |
Write SQL query to solve given problem: How much is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT TaxAmt, PurchaseOrderID FROM PurchaseOrderHeader ORDER BY TaxAmt DESC LIMIT 1 |
Write SQL query to solve given problem: How many person have a projected yearly sales of no more than 50,000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(BusinessEntityID) FROM SalesPersonQuotaHistory WHERE SalesQuota < 500000 |
Write SQL query to solve given problem: Among the employees who were born before 1969, what is the work shift of the 6th oldest employee?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.StartTime, T3.EndTime FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE STRFTIME('%Y', T1.BirthDate) < '1969' ORDER BY T1.BirthDate LIMIT 5, 1 |
Write SQL query to solve given problem: Which product allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.Name, T2.Rating FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.DaysToManufacture = ( SELECT DaysToManufacture FROM Product ORDER BY DaysToManufacture LIMIT 1 ) ORDER BY T1.ListPrice - T1.StandardCost DESC LIMIT 1 |
Write SQL query to solve given problem: What are the full names of the sales person whose bonuses are less than 1,000?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Bonus < 1000 |
Write SQL query to solve given problem: When did the Senior Tool Designer, who was 33 years old at the time he was hired, stopped working in the Engineering department?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.EndDate FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T1.JobTitle = 'Senior Tool Designer' AND STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 33 AND T2.EndDate IS NOT NULL |
Write SQL query to solve given problem: Among the vendors with an average credit rating, what is the overall total due amount of purchases made by the company to the vendor that isn't preferrerd if another vendor is available?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(T2.TotalDue) FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 4 AND T1.PreferredVendorStatus = 0 |
Write SQL query to solve given problem: Which department has the most number of night shifts?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.Name FROM Shift AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.ShiftId = T2.ShiftId INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID GROUP BY T2.DepartmentID ORDER BY COUNT(T1.Name = 'Night') DESC LIMIT 1 |
Write SQL query to solve given problem: How much profit can the company gained from selling two high class black Road Bikes with a size of 58?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT 2 * (T1.ListPrice - T1.StandardCost) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'H' AND T1.Color = 'Black' AND T1.Size = 58 AND T2.Name = 'Road Bikes' |
Write SQL query to solve given problem: What are the full names of the 10 youngest married male production technicians?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate DESC LIMIT 10 |
Write SQL query to solve given problem: Among the products with an average lead time of 60, which vendor has the highest profit on net? Indicate the credit rating of such vendor.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name, T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.AverageLeadTime = 60 ORDER BY T1.LastReceiptCost - T1.StandardPrice DESC LIMIT 1 |
Write SQL query to solve given problem: What is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.LastReceiptCost - T1.StandardPrice, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty = 200 |
Write SQL query to solve given problem: What is the full name of the non-sales employee who made the most number of rejected purchase orders?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) DESC LIMIT 1 |
Write SQL query to solve given problem: What are the names of the vendor with the second lowest minimum order quantity?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.MaxOrderQty ASC LIMIT 1, 1 |
Write SQL query to solve given problem: How much are the minimum orders of the vendors that are no longer used by the company?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.MinOrderQty FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ActiveFlag = 0 ORDER BY T2.MinOrderQty LIMIT 1 |
Write SQL query to solve given problem: Of the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate), T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.VacationHours <= 10 ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1 |
Write SQL query to solve given problem: What is the primary type of all single female employees hired between 1/1/2008 to 12/31/2008?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F' AND T1.MaritalStatus = 'S' AND STRFTIME('%Y-%m-%d', T1.HireDate) BETWEEN '2008-1-1' AND '2008-12-31' GROUP BY T2.PersonType ORDER BY COUNT(T2.PersonType) DESC LIMIT 1 |
Write SQL query to solve given problem: What is the company's profit on the product that was rated second-highest by David?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.ListPrice - T2.StandardCost FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ReviewerName = 'David' ORDER BY T1.Rating DESC LIMIT 1 |
Write SQL query to solve given problem: Which geographic area does the city with the second lowest tax rate belongs to? Indicate the name of the state or province as well.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T3.'Group', T2.Name FROM SalesTaxRate AS T1 INNER JOIN StateProvince AS T2 ON T1.StateProvinceID = T2.StateProvinceID INNER JOIN SalesTerritory AS T3 ON T2.TerritoryID = T3.TerritoryID ORDER BY T1.TaxRate LIMIT 1, 1 |
Write SQL query to solve given problem: Which seasonal discount had the highest discount percentage?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Description FROM SpecialOffer WHERE Type = 'Seasonal Discount' ORDER BY DiscountPct DESC LIMIT 1 |
Write SQL query to solve given problem: Please list the top 3 discounts with the highest discount percentage and fall under the reseller category.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Description, DiscountPct FROM SpecialOffer WHERE Category = 'Reseller' ORDER BY DiscountPct DESC LIMIT 0, 3 |
Write SQL query to solve given problem: Among all the products that are manufactured in-house, how many of them are salable?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT SUM(FinishedGoodsFlag) FROM Product WHERE MakeFlag = 1 |
Write SQL query to solve given problem: Which product has the highest standard cost?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT Name FROM Product ORDER BY StandardCost DESC LIMIT 1 |
Write SQL query to solve given problem: Please list the e-mail addresses of all the employees who wish to receive e-mail promotions from Adventureworks and selected partners.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.EmailAddress FROM Person AS T1 INNER JOIN EmailAddress AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.EmailPromotion = 2 |
Write SQL query to solve given problem: Please list the names of all the store contact employees whose credit cards expired in 2007.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN CreditCard AS T3 ON T2.CreditCardID = T3.CreditCardID WHERE T3.ExpYear = 2007 AND T1.PersonType = 'SC' |
Write SQL query to solve given problem: How many people were there in the Engineering Department in the year 2009?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM Person AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' AND STRFTIME('%Y', T2.EndDate) > '2009' AND STRFTIME('%Y', T2.StartDate) < '2009' |
Write SQL query to solve given problem: Which employee has been in the Engineering Department the longest? Please give his or her firstname and lastname.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' ORDER BY T2.EndDate - T2.StartDate DESC LIMIT 1 |
Write SQL query to solve given problem: Among the employees in the Manufacturing group in 2007, how many of them are store contacts?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN Person AS T3 ON T1.BusinessEntityID WHERE T3.PersonType = 'SC' AND T2.GroupName = 'Manufacturing' AND STRFTIME('%Y', T1.EndDate) >= '2007' AND STRFTIME('%Y', T1.StartDate) <= '2007' |
Write SQL query to solve given problem: How many employees working in the Engineering Department in 2007 would have their credit cards expired in the same year?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID INNER JOIN PersonCreditCard AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID INNER JOIN CreditCard AS T4 ON T3.CreditCardID = T4.CreditCardID WHERE T4.ExpYear = 2007 AND T2.Name = 'Engineering' |
Write SQL query to solve given problem: What is the e-mail address of the employee who switched departments for the most times?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT T2.EmailAddress FROM EmployeeDepartmentHistory AS T1 INNER JOIN EmailAddress AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID GROUP BY T2.BusinessEntityID ORDER BY COUNT(T1.DepartmentID) DESC LIMIT 1 |
Write SQL query to solve given problem: Among all the employees who don't wish to receive promotion e-mails, how many of them belong to or once belonged to the Engineering Department?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T1.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Engineering' AND T2.EmailPromotion = 0 |
Write SQL query to solve given problem: How many employees came into the Quality Assurance Group in the year 2007?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.GroupName = 'Quality Assurance' AND STRFTIME('%Y', T1.StartDate) = '2007' |
Write SQL query to solve given problem: Has the product Chainring Bolts been on any of the sales?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CASE WHEN COUNT(T1.Description) >= 1 THEN 'Yes' ELSE 'No' END FROM SpecialOffer AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN Product AS T3 ON T2.ProductID = T3.ProductID WHERE T3.Name = 'Chainring Bolts' |
Write SQL query to solve given problem: Please list the products that are under the Clothing category that are manufactured in-house and salable.. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CASE WHEN T1.MakeFlag = 1 THEN T1.Name END FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID INNER JOIN ProductCategory AS T3 ON T2.ProductCategoryID = T3.ProductCategoryID WHERE T2.ProductSubcategoryID = 3 |
Write SQL query to solve given problem: For all the employees that have left the Engineering Department, what is the average time of their stay?. Keep the solution inside sql tag ```sql [SQL-Query] ``` | works_cycles | SELECT CAST(SUM(365 * (STRFTIME('%Y', T1.EndDate) - STRFTIME('%Y', T1.StartDate)) + 30 * (STRFTIME('%m', T1.EndDate) - STRFTIME('%m', T1.StartDate)) + STRFTIME('%d', T1.EndDate) - STRFTIME('%d', T1.StartDate)) AS REAL) / COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.Name = 'Engineering' AND T1.EndDate IS NOT NULL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.