problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: How many of the workers who started working in 2009 are from the Production Department?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.StartDate >= '2009-01-01' AND T2.StartDate < '2010-01-01' AND T1.Name = 'Production'
Write SQL query to solve given problem: Who is the company's highest-paid single female employee? Include her full name and job title.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T3.FirstName, T3.MiddleName, T3.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'F' ORDER BY T2.Rate DESC LIMIT 1
Write SQL query to solve given problem: Who is the Vice President of Engineering and when did he join the company? Indicate his/her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.HireDate FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Vice President of Engineering'
Write SQL query to solve given problem: How many active employees whose payrate is equal or below 30 per hour.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Rate <= 30
Write SQL query to solve given problem: Which department has a worker who just recently started working?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Name FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID ORDER BY T2.StartDate DESC LIMIT 1
Write SQL query to solve given problem: How frequently do the employee with the least number of sick leave hours 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 ORDER BY T1.SickLeaveHours ASC LIMIT 1
Write SQL query to solve given problem: Which job title has the lowest pay?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.Rate ASC LIMIT 1
Write SQL query to solve given problem: What is the profit of the product with the highest list price and of the product with the lowest list price other than 0? Indicates the depth the component is from its parent.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice DESC LIMIT 1 ) , ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice LIMIT 1 )
Write SQL query to solve given problem: Among the companies to which Adventure Works Cycles purchases parts or other goods, what is the profit on net obtained from the vendor who has an above average credit rating? Kindly indicate each names of the vendor and the corresponding net profits.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name, T1.LastReceiptCost - T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CreditRating = 3
Write SQL query to solve given problem: What is the postal code of the street address of the account that is latest updated?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT PostalCode FROM Address ORDER BY ModifiedDate DESC LIMIT 1
Write SQL query to solve given problem: What is the longest assembly item duration for bicycles?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT JULIANDAY(EndDate) - JULIANDAY(StartDate) FROM BillOfMaterials ORDER BY JULIANDAY(EndDate) - JULIANDAY(StartDate) DESC LIMIT 1
Write SQL query to solve given problem: Please list the unit measure code of the component that is of the greatest need in quantity to create the assembly.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT UnitMeasureCode FROM BillOfMaterials ORDER BY PerAssemblyQty DESC LIMIT 1
Write SQL query to solve given problem: Please list the titles of the documents that are pending approval.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Title FROM Document WHERE Status = 1
Write SQL query to solve given problem: Please list the job titles of the employees who has a document that has been approved.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT T2.BusinessEntityID, T2.JobTitle FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 2
Write SQL query to solve given problem: What is the pay frequency of the oldest employee?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.PayFrequency FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.BirthDate ASC LIMIT 1
Write SQL query to solve given problem: Among the employees whose pay frequencies are the highest, how many of them are married?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T1.PayFrequency = ( SELECT PayFrequency FROM EmployeePayHistory ORDER BY PayFrequency DESC LIMIT 1 )
Write SQL query to solve given problem: For the employee who has been hired the latest, what is his or her pay rate?. 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 ORDER BY T2.HireDate DESC LIMIT 1
Write SQL query to solve given problem: Among the employees who have a pay rate of above 40, how many of them are male?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(CASE WHEN T2.Gender = 'M' THEN 1 ELSE 0 END) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate > 40
Write SQL query to solve given problem: What is the highest pay rate of the employees who are exempt from collective bargaining?. 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 WHERE T2.SalariedFlag = 1 ORDER BY T1.Rate DESC LIMIT 1
Write SQL query to solve given problem: For the employees who have the highest pay frequency, please list their vacation hours.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.VacationHours FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.BusinessEntityID = ( SELECT BusinessEntityID FROM EmployeePayHistory ORDER BY Rate DESC LIMIT 1 )
Write SQL query to solve given problem: What is the pay rate of the employee who has the longest vacation hours?. 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 ORDER BY T2.VacationHours DESC LIMIT 1
Write SQL query to solve given problem: How many employees with a pay rate of over 35 have more than 10 sick leave hours?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SickLeaveHours > 10 AND T1.Rate > 35
Write SQL query to solve given problem: Among the active male employees, how many of them are paid with the highest frequency?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.Gender = 'M' AND T1.PayFrequency = 2
Write SQL query to solve given problem: What is the job position of the oldest employee?. 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 ORDER BY T1.BirthDate ASC LIMIT 1
Write SQL query to solve given problem: What is the name style of the employee with the lowest pay rate?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.NameStyle FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate IS NOT NULL ORDER BY T1.Rate ASC LIMIT 1
Write SQL query to solve given problem: Among the employees who are married, how many of them have a western name style?. 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.NameStyle = 0 AND T1.MaritalStatus = 'M'
Write SQL query to solve given problem: Among the employees who have more than 10 hours of sick leave, how many of them wish to receive e-mail promotions?. 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 = 1 AND T1.SickLeaveHours > 10
Write SQL query to solve given problem: Please list the employees who have more than 20 vacations hours and wish to receive e-mail promotions.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.VacationHours > 20
Write SQL query to solve given problem: Please give the additional contact information of the oldest employee with the jod position of sales person.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.AdditionalContactInfo FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE PersonType = 'SP' ORDER BY T1.BirthDate ASC LIMIT 1
Write SQL query to solve given problem: What is the first name of the male employee who has a western name style?. 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 T2.NameStyle = 0 AND T1.Gender = 'M'
Write SQL query to solve given problem: Among the active employees, how many of them have a courtesy title of "Mr"?. 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 T1.CurrentFlag = 1 AND T2.Title = 'Mr.'
Write SQL query to solve given problem: Please give the personal information of the married employee who has the highest pay rate.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Demographics FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' ORDER BY T3.Rate DESC LIMIT 1
Write SQL query to solve given problem: What is the surname suffix of the employee who works as a store contact and has the longest sick leave hours?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Suffix FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP' ORDER BY T1.SickLeaveHours DESC LIMIT 1
Write SQL query to solve given problem: Among the married employees with the highest pay frequency, how many of them have an eastern name style?. 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 INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' AND T2.NameStyle = 1 AND T3.Rate = ( SELECT Rate FROM EmployeePayHistory ORDER BY Rate DESC LIMIT 1 )
Write SQL query to solve given problem: How many active employees do not wish to receive e-mail promotions?. 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 T1.CurrentFlag = 1 AND T2.EmailPromotion = 1
Write SQL query to solve given problem: Among the employees who are married and wish to receive e-mail promotions, how much higher is their highest pay rate from the average pay rate?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT MAX(T1.Rate) - SUM(T1.Rate) / COUNT(T1.BusinessEntityID) 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 T2.EmailPromotion = 2 AND T3.MaritalStatus = 'M'
Write SQL query to solve given problem: If a married employee has a western name style, what is the probability of him or her working as a store contact?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(COUNT(IIF(T1.PersonType = 'SC', T1.PersonType, NULL)) AS REAL) / COUNT(T1.PersonType) FROM Person AS T1 INNER JOIN Employee AS T2 WHERE T1.PersonType = 'SC' AND T1.NameStyle = 0 AND T2.MaritalStatus = 'M'
Write SQL query to solve given problem: Among the active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10
Write SQL query to solve given problem: Average of the last receipt cost of the products whose average lead time is 60 days.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(LastReceiptCost) / COUNT(ProductID) FROM ProductVendor WHERE AverageLeadTime = 60
Write SQL query to solve given problem: Average cost of purchase orders made during the first six months of 2012.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01'
Write SQL query to solve given problem: What percentage of male employees hired throughout the years 2009 are married?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee WHERE SUBSTR(HireDate, 1, 4) = '2009' AND Gender = 'M'
Write SQL query to solve given problem: What percentage of people named Mary who wants Receive Email promotions of AdventureWorks and selected partners are store contacts?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN EmailPromotion = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN PersonType = 'SC' THEN 1 ELSE 0 END) FROM Person WHERE FirstName = 'Mary'
Write SQL query to solve given problem: List, by ProductID, all products whose profit, relative to the standard price, is negative.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT ProductID FROM ProductVendor WHERE StandardPrice - LastReceiptCost < 0
Write SQL query to solve given problem: What is the average total due price of products with approved status?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(TotalDue) / COUNT(TotalDue) FROM PurchaseOrderHeader WHERE Status = 2
Write SQL query to solve given problem: What is the percentage, by number of sales order units, for orders with quantities not greater than 3 and a discount of 0.2?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN OrderQty < 3 AND UnitPriceDiscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / COUNT(SalesOrderID) FROM SalesOrderDetail
Write SQL query to solve given problem: Lists all companies by BusinessEntityID that increased their current year sales by more than 60% over last year's sales and have a bonus greater than 3,000.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BusinessEntityID FROM SalesPerson WHERE SalesYTD > SalesLastYear + SalesLastyear * 0.6 AND Bonus > 3000
Write SQL query to solve given problem: Add the number of businesses that indicate their home address as their address and those whose address corresponds to the shipping address.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(CASE WHEN T2.Name = 'Home' THEN 1 ELSE 0 END) , SUM(CASE WHEN T2.Name = 'Shipping' THEN 1 ELSE 0 END) FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID
Write SQL query to solve given problem: Identifies the ID number of the customer whose sales order for 32 units had a unit price of 35.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.CustomerID FROM SalesOrderDetail AS T1 INNER JOIN Customer AS T2 WHERE T1.UnitPrice = 35 AND T1.OrderQty = 32
Write SQL query to solve given problem: What company has a Colonial Voice card that expired in March 2005?. 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.CardType = 'ColonialVoice' AND T1.ExpMonth = 3 AND T1.ExpYear = 2005
Write SQL query to solve given problem: What is the credit rating of the company whose average lead time is 16 days for a standard price of 18.9900 and whose last receipt date is August 27, 2011?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.StandardPrice = 18.9900 AND T1.AverageLeadTime = 16 AND STRFTIME('%Y-%m-%d', T1.LastReceiptDate) = '2011-08-27'
Write SQL query to solve given problem: Calculate the number of products if we add the products of the accessories and components categories.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(ProductID) FROM Product WHERE Name LIKE '%accessories %' OR Name LIKE '%components%'
Write SQL query to solve given problem: What is the job title of the newest employee in department 12?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.DepartmentID = 12 ORDER BY T2.StartDate DESC LIMIT 1
Write SQL query to solve given problem: Sum the total number of products rejected for having a trim length that is too long.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long'
Write SQL query to solve given problem: Calculate the total quantity of purchased product that has been prepared by employee number 257 and is in pending shipment status.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(T2.OrderQty) FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID WHERE T1.Status = 1
Write SQL query to solve given problem: If we discount the products that do not have any type of offer, how many different products have been sold in an amount greater than 2 units per order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(DISTINCT T1.ProductID) FROM SalesOrderDetail AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN SpecialOffer AS T3 ON T2.SpecialOfferID = T3.SpecialOfferID WHERE T1.OrderQty > 2 AND T1.UnitPriceDiscount = 0
Write SQL query to solve given problem: What type of transaction was made with the only yellow product, size 62 and with a minimum inventory stock of 500 units?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DISTINCT T2.TransactionType FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Size = 62 AND T1.Color = 'Yellow' AND T1.SafetyStockLevel = 500
Write SQL query to solve given problem: What is the product cost end date with the highest weight in grams?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.EndDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.WeightUnitMeasureCode = 'G' ORDER BY T1.Weight DESC LIMIT 1
Write SQL query to solve given problem: What is the percentage of the total products ordered were not rejected by Drill size?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10
Write SQL query to solve given problem: Calculate the average of the total ordered quantity of products purchased whose shipping method was Cargo Transport 5.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(IIF(T1.ShipMethodID = 5, T3.OrderQty, 0)) AS REAL) / COUNT(T3.ProductID) FROM ShipMethod AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.ShipMethodID = T2.ShipMethodID INNER JOIN PurchaseOrderDetail AS T3 ON T2.PurchaseOrderID = T3.PurchaseOrderID
Write SQL query to solve given problem: List the name of the rates that apply to the provinces that are in the territory that obtained the greatest increase in sales with respect to the previous year.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM SalesTerritory AS T1 INNER JOIN StateProvince AS T2 ON T1.CountryRegionCode = T2.CountryRegionCode INNER JOIN SalesTaxRate AS T3 ON T2.StateProvinceID = T3.StateProvinceID ORDER BY (T1.SalesYTD - T1.SalesLastYear) / T1.SalesLastYear DESC LIMIT 1
Write SQL query to solve given problem: How many employees earn their salaries on a monthly basis at an hourly rate of more than 50?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(BusinessEntityID) FROM EmployeePayHistory WHERE rate * PayFrequency > 50
Write SQL query to solve given problem: What is the employee of company number 1's full name?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT FirstName, MiddleName, LastName FROM Person WHERE BusinessEntityID = 1 AND PersonType = 'EM'
Write SQL query to solve given problem: What is the name of the supplier number 1492?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT NAME FROM Vendor WHERE BusinessEntityID = 1492
Write SQL query to solve given problem: How many vendors only consented to move on with the 500 to 15000 piece order in terms of quality?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(*) FROM ProductVendor WHERE MinOrderQty > 500 AND MaxOrderQty < 15000
Write SQL query to solve given problem: Please list the departments that are part of the Executive General and Administration group.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Department WHERE GroupName = 'Executive General and Administration'
Write SQL query to solve given problem: How many vendors are having their products ordered with an average delivery time of 25 days?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(DISTINCT BusinessEntityID) FROM ProductVendor WHERE AverageLeadTime = 25
Write SQL query to solve given problem: Please list any 3 product numbers with the lowest standard cost.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ProductID FROM ProductCostHistory ORDER BY StandardCost ASC LIMIT 3
Write SQL query to solve given problem: How many black-colored products are there that cannot be sold?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT COUNT(ProductID) FROM Product WHERE FinishedGoodsFlag = 0 AND Color = 'Black'
Write SQL query to solve given problem: Please list the top three employees with the most unused sick leave along with their position titles.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT JobTitle FROM Employee ORDER BY SickLeaveHours DESC LIMIT 3
Write SQL query to solve given problem: What is the full address of address number 11906?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT AddressLine1, AddressLine2 FROM Address WHERE AddressID = 11906
Write SQL query to solve given problem: What is business number 1580's net profit?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT LastReceiptCost - StandardPrice FROM ProductVendor WHERE BusinessEntityID = 1580
Write SQL query to solve given problem: What is the sales revenue for item number 740?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ListPrice - StandardCost FROM Product WHERE ProductID = 740
Write SQL query to solve given problem: How many customers gave a product the best possible rating? Please list their names.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ReviewerName FROM ProductReview WHERE Rating = 5
Write SQL query to solve given problem: What are the company that Adventure Works deal with that have poor credit rating? Please provide their business number.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BusinessEntityID FROM Vendor WHERE CreditRating = ( SELECT CreditRating FROM Vendor ORDER BY CreditRating DESC LIMIT 1 )
Write SQL query to solve given problem: What is the forename and birthdate of person number 18?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.FirstName, T2.BirthDate FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.BusinessEntityID = 18
Write SQL query to solve given problem: What job is person number 322 currently holding?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Name FROM ContactType AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.ContactTypeID = T2.ContactTypeID WHERE T2.BusinessEntityID = 332
Write SQL query to solve given problem: Please list 3 businesses along with their IDs that use cellphones.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.BusinessEntityID FROM PhoneNumberType AS T1 INNER JOIN PersonPhone AS T2 ON T1.PhoneNumberTypeID = T2.PhoneNumberTypeID WHERE T1.Name = 'Cell' LIMIT 3
Write SQL query to solve given problem: How long does it take for the business to receive the item it has purchased? Who is the vendor for business number 1496?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.AverageLeadTime, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 USING (businessentityid) WHERE T2.BusinessEntityID = 1496 GROUP BY T1.AverageLeadTime, T2.Name
Write SQL query to solve given problem: How many accounts are in Bothell as opposed to Kenmore? What is the name of the State that comprises these two cities?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(IIF(T1.city = 'Bothell', 1, 0)) - SUM(IIF(T1.city = 'Kenmore', 1, 0)) , stateprovincecode FROM Address AS T1 INNER JOIN StateProvince AS T2 ON T1.stateprovinceid = T2.stateprovinceid GROUP BY stateprovincecode
Write SQL query to solve given problem: Which chromoly steel product model has AdventureWorks saved in English?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.ProductModelID FROM ProductModelProductDescriptionCulture AS T1 INNER JOIN Culture AS T2 USING (cultureid) INNER JOIN ProductDescription AS T3 USING (productdescriptionid) WHERE T3.Description LIKE 'Chromoly steel%' AND T2.Name = 'English'
Write SQL query to solve given problem: Please list the total number of companies with a commission percentage of 0.018 or above, along with each company's assigned geographical location.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.BusinessEntityID, T2.'Group' FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 USING (territoryid) WHERE T1.CommissionPct >= 0.018
Write SQL query to solve given problem: Which role has the most common contact among businesses?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Name FROM ContactType AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.ContactTypeID = T2.ContactTypeID GROUP BY T1.Name ORDER BY COUNT(T1.Name) DESC LIMIT 1
Write SQL query to solve given problem: How much do the works data saved in English and Arabic differ from one another?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT SUM(CASE WHEN T1.Name = 'English' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID WHERE T1.Name = 'English' OR T1.Name = 'Arabic'
Write SQL query to solve given problem: What is the location of business number 1?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 USING (AddressID) WHERE T2.BusinessEntityID = 1
Write SQL query to solve given problem: What percentage of the AdventureWorks data is in Thai?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.CultureID) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID
Write SQL query to solve given problem: What percentage of AdventureWorks employees are men?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT CAST(SUM(CASE WHEN T2.Gender = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessentityID) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessentityID = T2.BusinessentityID WHERE T1.PersonType = 'EM'
Write SQL query to solve given problem: Where is the address 15873 located, in what city and state? Does that city belong to a province where the code exists?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.City, T1.Name, T1.IsOnlyStateProvinceFlag FROM StateProvince AS T1 INNER JOIN Address AS T2 ON T1.StateProvinceID = T2.StateProvinceID WHERE T2.AddressID = 15873
Write SQL query to solve given problem: What is the full address of business number 24?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.AddressLine1, T1.AddressLine2 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 24
Write SQL query to solve given problem: Which year is credit card No.9648's Expiration Year?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT ExpYear FROM CreditCard WHERE CreditCardID = 9648
Write SQL query to solve given problem: What is the location id for Debur and Polish?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT LocationID FROM Location WHERE Name = 'Debur and Polish'
Write SQL query to solve given problem: What are the Department ids under the Sales and Marketing Group?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT DepartmentID FROM Department WHERE GroupName = 'Sales and Marketing'
Write SQL query to solve given problem: Which sales person made the sale of 1635823.3967 last year? Give the Business Entity ID.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BusinessEntityID FROM SalesPerson WHERE SalesLastYear = '1635823.3967'
Write SQL query to solve given problem: What is the Shift start time for Shift ID No.2?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT StartTime FROM Shift WHERE ShiftID = '2'
Write SQL query to solve given problem: What is contact Type ID No.16 represent for?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM ContactType WHERE ContactTypeID = '16'
Write SQL query to solve given problem: Please tell the meaning of CultureID "fr".. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT Name FROM Culture WHERE CultureID = 'fr'
Write SQL query to solve given problem: For the older production technician who was hired in 2008/12/7, what's his/her birthday?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT BirthDate FROM Employee WHERE HireDate = '2008-12-07'
Write SQL query to solve given problem: What is the product ID No.793's model name?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductModel AS T2 ON T1.ProductModelID = T2.ProductModelID WHERE T1.ProductID = 793
Write SQL query to solve given problem: What are the unit measure codes for product ID No.762?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.UnitMeasureCode FROM Product AS T1 INNER JOIN UnitMeasure AS T2 ON T1.SizeUnitMeasureCode = T2.UnitMeasureCode OR T1.WeightUnitMeasureCode = T2.UnitMeasureCode WHERE T1.ProductID = 762 GROUP BY T1.ProductID, T2.UnitMeasureCode
Write SQL query to solve given problem: Where is Business Entity ID No.4 located at? Give the address down to street.. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT AddressLine1, AddressLine2 FROM Address WHERE AddressID IN ( SELECT AddressID FROM BusinessEntityAddress WHERE BusinessEntityID = 4 )
Write SQL query to solve given problem: For the on going assembly item Component ID No. 494, what's the Unit measure for it?. Keep the solution inside sql tag ```sql [SQL-Query] ```
works_cycles
SELECT T2.Name FROM BillOfMaterials AS T1 INNER JOIN UnitMeasure AS T2 ON T1.UnitMeasureCode = T2.UnitMeasureCode WHERE T1.ComponentID = 494 AND T1.EndDate IS NULL GROUP BY T2.name