problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: For the document Control Assistant who was born on 1975/12/25, how many private documents did he/she have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T2.BusinessEntityID) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T2.JobTitle = 'Document Control Assistant' AND T2.BirthDate = '1975-12-25' AND T1.DocumentSummary IS NULL
Write SQL query to solve given problem: To the products which could make the profit as 21.9037, what were their list price after October of 2012?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ListPrice - T1.StandardCost > 21.9037 AND STRFTIME('%Y-%m-%d', T2.StartDate) >= '2012-10-01'
Write SQL query to solve given problem: What is the size of the photo of product id No.1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ThumbNailPhoto FROM ProductPhoto AS T1 INNER JOIN ProductProductPhoto AS T2 ON T1.ProductPhotoID = T2.ProductPhotoID WHERE T2.ProductID = 1
Write SQL query to solve given problem: What is the number of State Province of France that doesn't have a State Province Code?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.CountryRegionCode FROM StateProvince AS T1 INNER JOIN CountryRegion AS T2 ON T1.CountryRegionCode = T2.CountryRegionCode WHERE T2.Name = 'France' AND T1.IsOnlyStateProvinceFlag = 1
Write SQL query to solve given problem: What kind of transaction type for the "HL Road Frame - Black, 48" order happened in 2012/12/13?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.TransactionType FROM TransactionHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'HL Road Frame - Black, 48' AND STRFTIME('%Y-%m-%d',T1.TransactionDate) = '2013-07-31'
Write SQL query to solve given problem: Which type of transaction was it for the "LL Road Handlebars" order happened in 2012/11/3?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.TransactionType FROM TransactionHistoryArchive AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'LL Road Handlebars' AND STRFTIME('%Y-%m-%d',T1.TransactionDate) = '2012-11-03'
Write SQL query to solve given problem: How is the Credit Rating for company whose rowguid is "33671A4E-DF2B-4879-807B-E3F930DD5C0C"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.CreditRating FROM Vendor AS T1 INNER JOIN BusinessEntity AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.rowguid = '33671A4E-DF2B-4879-807B-E3F930DD5C0C'
Write SQL query to solve given problem: What is the PreferredVendorStatus for the company which has the rowguid of "684F328D-C185-43B9-AF9A-37ACC680D2AF"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.PreferredVendorStatus FROM Vendor AS T1 INNER JOIN BusinessEntity AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.rowguid = '684F328D-C185-43B9-AF9A-37ACC680D2AF'
Write SQL query to solve given problem: For person id No.2054, is his/her vendor still active?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ActiveFlag FROM Vendor AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonID = 2054
Write SQL query to solve given problem: Which is Business Entity ID No.13626's phone number type?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM PersonPhone AS T1 INNER JOIN PhoneNumberType AS T2 USING (PhoneNumberTypeID) WHERE T1.BusinessEntityID = 13626
Write SQL query to solve given problem: For the document Control Assistant who was hired on 2009/1/22, what is the percentage of private documents did he/she have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T1.DocumentSummary IS NOT NULL THEN 1 ELSE 0 END) AS REAL) / COUNT(T1.DocumentSummary) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T2.JobTitle = 'Document Control Assistant' AND T2.HireDate = '2009-01-22'
Write SQL query to solve given problem: For all phone numbers, what percentage of the total is cell phone?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T2.Name = 'Cell' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.Name) FROM PersonPhone AS T1 INNER JOIN PhoneNumberType AS T2 ON T1.PhoneNumberTypeID = T2.PhoneNumberTypeID
Write SQL query to solve given problem: What are the product assembly ID that come with unit measure code EA and BOM level of 2, at the same time have per assembly quantity of more than 10?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ProductAssemblyID FROM BillOfMaterials WHERE UnitMeasureCode = 'EA' AND BOMLevel = 2 AND PerAssemblyQty > 10
Write SQL query to solve given problem: How many location IDs have actual resource hours of 2?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(LocationID) FROM WorkOrderRouting WHERE ActualResourceHrs = 2
Write SQL query to solve given problem: What is the stocked quantity of products manufactured from location ID 40?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(*) FROM WorkOrderRouting AS T1 INNER JOIN BillOfMaterials AS T2 ON T1.LocationID = T2.ProductAssemblyID INNER JOIN WorkOrder AS T3 ON T3.WorkOrderID = T1.WorkOrderID WHERE T1.LocationID = 40
Write SQL query to solve given problem: What is the job position currently occupied by Ken J Sánchez?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.FirstName = 'Ken' AND T2.MiddleName = 'J' AND T2.LastName = 'Sánchez'
Write SQL query to solve given problem: How many male employees do not wish to receive e-mail promotion?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 0 AND T1.Gender = 'M'
Write SQL query to solve given problem: Who is the top sales person who achived highest percentage of projected sales quota in 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BusinessEntityID FROM SalesPerson WHERE BusinessEntityID IN ( SELECT BusinessEntityID FROM SalesPersonQuotaHistory WHERE STRFTIME('%Y', QuotaDate) = '2013' ) ORDER BY CAST(SalesLastYear AS REAL) / SalesQuota DESC LIMIT 1
Write SQL query to solve given problem: What is the total sick leave hours of employees who do not wish to receive any e-mail promotion?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(T1.SickLeaveHours) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 0
Write SQL query to solve given problem: Among the sales people, who are hired prior to 2010?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP' AND SUBSTR(T1.HireDate, 0, 4) < 2010
Write SQL query to solve given problem: Which sales person achieved the highest sales YTD? What is the projected yearly sales quota in 2011 for this person?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.BusinessEntityID, SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2011' GROUP BY T1.BusinessEntityID ORDER BY SUM(T1.SalesYTD) DESC LIMIT 1
Write SQL query to solve given problem: How many people with the name Alex are single and occupying organization level of 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.FirstName = 'Alex' AND T1.MaritalStatus = 'S' AND T1.OrganizationLevel = 1
Write SQL query to solve given problem: State the last name and job title of owner for document "Crank Arm and Tire Maintenance".. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.LastName, T3.JobTitle FROM Person AS T1 INNER JOIN Document AS T2 ON T1.BusinessEntityID = T2.Owner INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T2.Title = 'Crank Arm and Tire Maintenance'
Write SQL query to solve given problem: Among the sales people who achieved projected sales quota 2013, is there any person from territory ID 1? If yes, state the business entity ID.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT T1.BusinessEntityID FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.TerritoryID = 1 AND STRFTIME('%Y', QuotaDate) = '2013'
Write SQL query to solve given problem: Who are the employees that submitted resume to Human Resource Department and got hired? State the last name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T3.LastName FROM Employee AS T1 INNER JOIN JobCandidate AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T1.BusinessEntityID IN (212, 274)
Write SQL query to solve given problem: What are the color of products that were reviewed?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Color FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID = 709 OR 937 OR 798
Write SQL query to solve given problem: What is the projected sales quota amount in 2013 and sales YTD amount for sales person with business entity ID 275?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.BusinessEntityID = 275 AND STRFTIME('%Y', QuotaDate) = '2013'
Write SQL query to solve given problem: Provide the business entity ID who did not achieved projected yearly sales quota in 2013.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT T1.BusinessEntityID FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013' AND T1.SalesQuota < T1.SalesLastYear
Write SQL query to solve given problem: Among the employees who wish to receive e-mail promotion from AdventureWorks, how many percent of them are female?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T1.Gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1
Write SQL query to solve given problem: How many times is married non sales employees against single non-sales employees?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T1.MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.MaritalStatus = 'S' THEN 1 ELSE 0 END) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'EM'
Write SQL query to solve given problem: How much is the total bonus received by sales person and what is the percentage of it against the projected yearly sales quota in 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(T1.Bonus) , CAST(SUM(T1.Bonus) AS REAL) * 100 / SUM(T1.SalesQuota) FROM SalesPerson AS T1 INNER JOIN SalesPersonQuotaHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T2.QuotaDate) = '2013'
Write SQL query to solve given problem: How many types of credit cards are there and how many are vista?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(CardNumber) FROM CreditCard WHERE CardType = 'vista'
Write SQL query to solve given problem: What is the name of the product with the id "475"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Product WHERE ProductID = 475
Write SQL query to solve given problem: Among the employees born before 1980 , how many of them are single?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 's' AND BirthDate < '1980-1-1'
Write SQL query to solve given problem: List all the names of the stores assigned to the sales person with the id "277".. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Store WHERE SalesPersonID = 277
Write SQL query to solve given problem: How many products with the id "989" were sold in August 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(Quantity) FROM TransactionHistory WHERE TransactionDate LIKE '2013-08%' AND TransactionType = 'S' AND ProductID = 989
Write SQL query to solve given problem: List all of the credit cards that had expired by 2007.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CardNumber FROM CreditCard WHERE ExpYear < 2007
Write SQL query to solve given problem: List all the pay rates of all employees that were hired at 20 years of age.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 20
Write SQL query to solve given problem: What is the name of the territory assigned to the sales person with business id "277"?. 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 WHERE T1.BusinessEntityID = 277
Write SQL query to solve given problem: What is the full name of the Vice President of Production?. 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 = 'Vice President of Production'
Write SQL query to solve given problem: List all the purchase order ids of the vendor with a below average rating.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.PurchaseOrderID FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 5
Write SQL query to solve given problem: Is the phone number "114-555-0100" a work number or a home number?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM PersonPhone AS T1 INNER JOIN PhoneNumberType AS T2 ON T1.PhoneNumberTypeID = T2.PhoneNumberTypeID WHERE T1.PhoneNumber = '114-555-0100'
Write SQL query to solve given problem: What is the total shipment by "cargo transport 5" cost of all purchase orders created on 12/14/2011?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(t2.freight) FROM ShipMethod AS t1 INNER JOIN PurchaseOrderHeader AS t2 ON t1.shipmethodid = t2.shipmethodid WHERE t1.name = 'cargo transport 5' AND t2.orderdate = '2011-12-14'
Write SQL query to solve given problem: What is the shipping address for the sales order "43873"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ShipToAddressID FROM SalesOrderHeader AS T1 INNER JOIN Address AS T2 ON T1.BillToAddressID = T2.AddressID WHERE T1.SalesOrderID = 43873 GROUP BY T1.ShipToAddressID
Write SQL query to solve given problem: List the first names of the people with more than 65 sick leave hours.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.SickLeaveHours > 65
Write SQL query to solve given problem: What proportion of sales orders are made from the United Kingdom?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T2.Name = 'United Kingdom' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.SalesOrderID) FROM SalesOrderHeader AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID
Write SQL query to solve given problem: When is the modified date of the phone number "1500 555-0143"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ModifiedDate FROM PersonPhone WHERE PhoneNumber = '1 (11) 500 555-0143'
Write SQL query to solve given problem: What is the business ID of the person who has made the most sales total year to date?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesYTD DESC LIMIT 1
Write SQL query to solve given problem: List all active vendors who offer a purchasing web service.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Vendor WHERE ActiveFlag = 1
Write SQL query to solve given problem: Which territory has the most customers as of 9/12/2014?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT TerritoryID FROM Customer WHERE ModifiedDate < '2014-12-09' GROUP BY TerritoryID ORDER BY COUNT(TerritoryID) DESC LIMIT 1
Write SQL query to solve given problem: What is the total cost for all the orders placed on 5/29/2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(TotalDue) FROM PurchaseOrderHeader WHERE OrderDate LIKE '2013-05-29%'
Write SQL query to solve given problem: What is the most common first name among the vendor contact?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT FirstName FROM Person WHERE PersonType = 'VC' GROUP BY FirstName ORDER BY COUNT(*) DESC LIMIT 1
Write SQL query to solve given problem: What is the person's business ID with a vista credit card number "11113366963373"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardNumber = 11113366963373
Write SQL query to solve given problem: Where does the person with the BusinessEntityID "5555" live?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T3.City, T3.AddressLine1 FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID INNER JOIN Address AS T3 ON T1.AddressID = T3.AddressID WHERE T1.BusinessEntityID = 5555 AND T2.Name = 'Home'
Write SQL query to solve given problem: List all the names of products with the special offer "15".. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM SpecialOfferProduct AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.SpecialOfferID = 15
Write SQL query to solve given problem: What is the reason for sales order "51883"?. 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 = 51883
Write SQL query to solve given problem: What is the credit card number for the sales order "45793"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.CardNumber FROM SalesOrderHeader AS T1 INNER JOIN CreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.SalesOrderID = 45793
Write SQL query to solve given problem: Which Production Technician has the highest pay rate?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' ORDER BY T2.Rate DESC LIMIT 1
Write SQL query to solve given problem: Who is the sales person in charge of the territory with the id "9"? Provide their full name.. 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.TerritoryID = 9
Write SQL query to solve given problem: What is the description of the discount for the product with the id "762"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Description FROM SpecialOfferProduct AS T1 INNER JOIN SpecialOffer AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.ProductID = 762
Write SQL query to solve given problem: What is the percentage of employees who work the night shift?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T1.Name = 'Night' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.BusinessEntityID) FROM Shift AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.ShiftId = T2.ShiftId
Write SQL query to solve given problem: How many married male employees were born before the year 1960?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(BusinessEntityID) FROM Employee WHERE MaritalStatus = 'M' AND STRFTIME('%Y', BirthDate) < '1960' AND Gender = 'M'
Write SQL query to solve given problem: What are the top 5 types of products with the highest selling price? ?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Product ORDER BY ListPrice DESC LIMIT 5
Write SQL query to solve given problem: In 2007, which job position was hired the most?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT JobTitle FROM Employee WHERE STRFTIME('%Y', HireDate) = '2007' GROUP BY HireDate ORDER BY COUNT(JobTitle) DESC LIMIT 1
Write SQL query to solve given problem: What is the profit on net of the vendor with the highest standard price? If there are two vendors of the same amount, calculate only for one vendor.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY StandardPrice DESC LIMIT 1
Write SQL query to solve given problem: How many departments did Sheela Ward work in between 1/1/2011 to 12/31/2012. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T3.Name) 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 T1.FirstName = 'Sheela' AND T1.LastName = 'Word' AND STRFTIME('%Y', T3.ModifiedDate) BETWEEN '2011' AND '2012'
Write SQL query to solve given problem: What is the average age of the sales agents in the company by 12/31/2009?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT AVG(2009 - STRFTIME('%Y', T2.BirthDate)) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SP'
Write SQL query to solve given problem: To which group does the department with the least amount of workers belong to? Indicate the name of the department as well.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.GroupName FROM EmployeeDepartmentHistory AS T1 INNER JOIN Department AS T2 ON T1.DepartmentID = T2.DepartmentID GROUP BY T2.GroupName ORDER BY COUNT(T1.BusinessEntityID) LIMIT 1
Write SQL query to solve given problem: What is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT 2015 - STRFTIME('%Y', T1.BirthDate), T2.Rate FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Marketing Specialist' ORDER BY 2015 - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1
Write SQL query to solve given problem: What is the total amount due of all the purchases made by the company to the vendor that has the lowest selling price amount of a single product? Indicate the name of the vendor to which the purchases was made.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.UnitPrice, T3.Name FROM PurchaseOrderDetail AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID INNER JOIN Vendor AS T3 ON T2.VendorID = T3.BusinessEntityID ORDER BY T1.UnitPrice LIMIT 1
Write SQL query to solve given problem: Who made the purchase order with the greatest total due before freight? Indicate her employee ID and calculate for his/her age when he/she was hired.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.BusinessEntityID, STRFTIME('%Y', T2.HireDate) - STRFTIME('%Y', T2.BirthDate) FROM PurchaseOrderHeader AS T1 INNER JOIN Employee AS T2 ON T1.EmployeeID = T2.BusinessEntityID ORDER BY T1.TotalDue DESC LIMIT 1
Write SQL query to solve given problem: What is the position of the employee with the 10th highest salary? Indicate his/her salary amount and his/her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.JobTitle, T1.Rate, T3.FirstName, T3.MiddleName, T3.LastName FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T1.Rate DESC LIMIT 9, 1
Write SQL query to solve given problem: What is the profit of a single product that received the highest rating from John Smith? List the product/s' names.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ListPrice - T1.StandardCost, T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ReviewerName = 'John Smith' ORDER BY T2.Rating DESC LIMIT 1
Write SQL query to solve given problem: What is the salary rate per hour that the company paid to the first 5 employees that they hired?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID ORDER BY T2.HireDate ASC LIMIT 0, 5
Write SQL query to solve given problem: Among the vendors with maximum orders betweeen 500 to 750, which vendor has the 10th highest profit on net?. 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.MaxOrderQty BETWEEN 500 AND 750 ORDER BY T1.LastReceiptCost - T1.StandardPrice DESC LIMIT 9, 1
Write SQL query to solve given problem: As of 12/31/2011, how long has the employee assigned to all pending for approval papers been working in the company from the date he was hired?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT 2011 - STRFTIME('%Y', T2.HireDate) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 1
Write SQL query to solve given problem: Jill ranked which medium-quality class product as the highest, and how long will it take the company to manufacture such a product?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.DaysToManufacture FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = 5 AND T1.Class = 'M' ORDER BY T2.Rating LIMIT 1
Write SQL query to solve given problem: What was the first job position that the company needed, and who was hired? Indicate his/her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.JobTitle, T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.HireDate LIMIT 1
Write SQL query to solve given problem: How many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.TransactionID) FROM TransactionHistory AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity BETWEEN 100 AND 250 AND T2.ReorderPoint <= 375
Write SQL query to solve given problem: What are the names of the vendors to which the company purchased its women's tights products?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT T4.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN ProductSubcategory AS T3 ON T1.ProductSubcategoryID = T3.ProductSubcategoryID INNER JOIN Vendor AS T4 ON T2.BusinessEntityID = T4.BusinessEntityID WHERE T1.MakeFlag = 0 AND T1.Style = 'W' AND T3.Name = 'Tights'
Write SQL query to solve given problem: How frequently does the first-ever Scheduling Assistant get paid?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle = 'Scheduling Assistant' ORDER BY T1.HireDate LIMIT 1
Write SQL query to solve given problem: What product has the fewest online orders from one customer? List the product's class, line of business, and list price.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Class, T2.ProductLine, T2.ListPrice FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID ORDER BY SUM(Quantity) LIMIT 1
Write SQL query to solve given problem: What is the full name of the sales person who has the the highest commission percent received per sale?. 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.CommissionPct DESC LIMIT 1
Write SQL query to solve given problem: What is the full name of the second oldest person in the company at the time he was hired?. 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 ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1, 1
Write SQL query to solve given problem: What is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT (T2.ListPrice - T2.StandardCost) * SUM(T1.Quantity), T2.Name FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T2.Name, T2.ListPrice, T2.StandardCost, T1.Quantity ORDER BY SUM(T1.Quantity) DESC LIMIT 1
Write SQL query to solve given problem: What is the highest amount of difference between the ordered quantity and actual quantity received in a single purchase order and to which vendor was the purchase order made?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.OrderQty - T2.ReceivedQty, VendorID FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID ORDER BY T2.OrderQty - T2.ReceivedQty DESC LIMIT 1
Write SQL query to solve given problem: What is the average lead time of product ID 843? Calculate for its profit on net and indicate the full location to which the vendor is located.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.AverageLeadTime, T1.LastReceiptCost - T1.StandardPrice, T4.AddressLine1, T4.AddressLine2 , T4.City, T4.PostalCode FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN BusinessEntityAddress AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID INNER JOIN Address AS T4 ON T3.AddressID = T4.AddressID WHERE T1.ProductID = 843
Write SQL query to solve given problem: How many salespersons haven't met quota?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(BusinessEntityID) FROM SalesPerson WHERE Bonus = 0
Write SQL query to solve given problem: Please give the highest product cost of a purchase order.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ActualCost FROM TransactionHistory WHERE TransactionType = 'P' ORDER BY ActualCost DESC LIMIT 1
Write SQL query to solve given problem: What is the current status of the order with the highest shipping cost?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Status FROM SalesOrderHeader ORDER BY Freight DESC LIMIT 1
Write SQL query to solve given problem: How many products are out of stock?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0
Write SQL query to solve given problem: What is the highest profit on net for a product?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY LastReceiptCost - StandardPrice DESC LIMIT 1
Write SQL query to solve given problem: Which reviewer gives the biggest number of the highest rating?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ReviewerName FROM ProductReview WHERE Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )
Write SQL query to solve given problem: Which product gets the most reviews?. 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 GROUP BY T1.ProductID ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1
Write SQL query to solve given problem: Among the products that are purchased, how many of them have never received the highest rating?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.ProductID) FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MakeFlag = 0 AND T1.Rating != 5
Write SQL query to solve given problem: What is the biggest amount of reviews a salable product gets?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Comments FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.FinishedGoodsFlag = 1 GROUP BY T1.Comments ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1
Write SQL query to solve given problem: Among the products that are both manufactured in house and salable, how many of them get over 10 reviews?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 USING (ProductID) WHERE T2.FinishedGoodsFlag = 1 AND T2.MakeFlag = 1 GROUP BY T2.Name ORDER BY COUNT(T1.COMMENTS) > 10
Write SQL query to solve given problem: Please list the names of the products that get over 10 reviews and a salable.. 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.FinishedGoodsFlag = 1 GROUP BY T2.NAME ORDER BY COUNT(T1.comments) > 10
Write SQL query to solve given problem: Please list the reviewers who have given the highest rating for a medium class, women's product.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ReviewerName FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'M' AND T2.Style = 'W' AND T1.Rating = 5
Write SQL query to solve given problem: What is the class of the product with the most reviews?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Class FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T2.Class ORDER BY COUNT(T1.ProductReviewID) DESC LIMIT 1