Chinastark/bird_dataset huggingface dataset:
Database: works_cycles
Question: To which group does the department with the least amount of workers belong to? Indicate the name of the department as well.
Evidence: least amount of workers refers to MIN(count(DepartmentID));
SQL: 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
Database: works_cycles
Question: What is the age of the oldest Marketing Specialist by 12/31/2015 and what is his/her hourly rate?
Evidence: age as of 12/31/2015 = SUBTRACT(2015, year(BirthDate)); hourly rate refers to Rate;
SQL: 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
Database: works_cycles
Question: 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.
Evidence: Vendor's selling price of a single product refers to UnitPrice;
SQL: 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
Database: works_cycles
Question: 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.
Evidence: total due before freight = SUBTRACT(TotalDue, Freight); age at the time an employee was hired = SUBTRACT(HireDate, year(BirthDate);
SQL: 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
Database: works_cycles
Question: What is the position of the employee with the 10th highest salary? Indicate his/her salary amount and his/her full name.
Evidence: salary and Rate are synonyms; full name = FirstName+MiddleName+LastName;
SQL: 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
Database: works_cycles
Question: What is the profit of a single product that received the highest rating from John Smith? List the product/s' names.
Evidence: highest rating refers to Rating = 5; profit = SUBTRACT(ListPrice, StandardCost);
SQL: 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
Database: works_cycles
Question: What is the salary rate per hour that the company paid to the first 5 employees that they hired?
Evidence: salary rate per hour refers to Rate; first 5 employees that were hired refers to 5 oldest HireDate;
SQL: 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
Database: works_cycles
Question: Among the vendors with maximum orders betweeen 500 to 750, which vendor has the 10th highest profit on net?
Evidence: maximum orders refers to MaxOrderQty; MaxOrderQty BETWEEN '500' AND '750'; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);
SQL: 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
Database: works_cycles
Question: 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?
Evidence: pending for approval papers refer to Status = 1; length of stay in the company as of 12/31/2011 = SUBTRACT(2011, year(HireDate));
SQL: SELECT 2011 - STRFTIME('%Y', T2.HireDate) FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 1
Database: works_cycles
Question: Jill ranked which medium-quality class product as the highest, and how long will it take the company to manufacture such a product?
Evidence: second-lowest rating refers to Rating = 2; high-quality class product refers to Class = 'H'; length of time it takes the company to manufacture a product refers to DaysToManufacture;
SQL: 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
Database: works_cycles
Question: What was the first job position that the company needed, and who was hired? Indicate his/her full name.
Evidence: job position and job title are synonyms; full name = FirstName+MiddleName+LastName;
SQL: 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
Database: works_cycles
Question: How many work orders with quantities ranging from 100 to 250 have a reorder point of no more than 375?
Evidence: work order refers to TransactionType = 'W'; Quantity BETWEEN 100 AND 250; ReorderPoint< = 375;
SQL: 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
Database: works_cycles
Question: How much is the average salary of female employees in comparison to male employees?
Evidence: female refers to Gender = 'F'; male refers to Gender = 'M'; difference in the average salary of female against male employees = SUBTRACT(AVG(Rate where Gender = 'F')), (AVG(Rate where Gender = 'M')));
SQL: SELECT AVG(T2.Rate) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F'
Database: works_cycles
Question: What are the names of the vendors to which the company purchased its women's tights products?
Evidence: product is purchased refers to MakeFlag = 0; women's refers to Style = 'W'; ProductSubcategoryID = 'Tights';
SQL: 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'
Database: works_cycles
Question: How frequently does the first-ever Scheduling Assistant get paid?
Evidence: PayFrequency = 1 refers to ‘Salary received monthly’; PayFrequency = 2 refers to ‘Salary received biweekly';
SQL: 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
Database: works_cycles
Question: What product has the fewest online orders from one customer? List the product's class, line of business, and list price.
Evidence: fewest online orders refer to MIN(Quantity);
SQL: 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
Database: works_cycles
Question: What is the full name of the sales person who has the the highest commission percent received per sale?
Evidence: commision percent received per sale refers to CommissionPct; highest commision percent received per sale refers to MAX(CommissionPcT); full name = FirstName+MiddleName+LastName;
SQL: 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
Database: works_cycles
Question: What is the full name of the second oldest person in the company at the time he was hired?
Evidence: age at the time of being hired = SUBTRACT(HireDate, BirthDate); full name = FirstName+MiddleName+LastName;
SQL: 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
Database: works_cycles
Question: 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.
Evidence: profit = MULTIPLY(SUBTRACT(ListPrice, Standardcost)), (Quantity)));
SQL: 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
Database: works_cycles
Question: 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?
Evidence: highest amount of difference between the ordered quantity and actual quantity received in a single purchase order refers to MAX(SUBTRACT(OrderQty, ReceivedQty));
SQL: 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
Database: works_cycles
Question: 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.
Evidence: Profit on net = SUBTRACT(LastReceiptCost, StandardPrice); full location = AddressLine1+AddressLine2+City+PostalCode;
SQL: 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
Database: works_cycles
Question: How many salespersons haven't met quota?
Evidence: salesperson that haven't met the quota refers to Bonus = 0;
SQL: SELECT COUNT(BusinessEntityID) FROM SalesPerson WHERE Bonus = 0
Database: works_cycles
Question: Among the sales with a tax applied to retail transaction, how many of them are charged by multiple types of taxes?
Evidence: tax applied to retail transaction refers to Taxtype = 1; sales that are charged with multiple types of tax refers to NAME LIKE '%+%';
SQL: SELECT COUNT(SalesTaxRateID) FROM SalesTaxRate WHERE Name LIKE '%+%'
Database: works_cycles
Question: Please give the highest product cost of a purchase order.
Evidence: product cost refers to ActualCost; purchase order refers to TransactionType = 'P';
SQL: SELECT ActualCost FROM TransactionHistory WHERE TransactionType = 'P' ORDER BY ActualCost DESC LIMIT 1
Database: works_cycles
Question: What is the current status of the order with the highest shipping cost?
Evidence: shipping cost and Freight are synonyms; highest shipping cost refers to MAX(Freight);
SQL: SELECT Status FROM SalesOrderHeader ORDER BY Freight DESC LIMIT 1
Database: works_cycles
Question: How many products are out of stock?
Evidence: out of stock product refers to OnOrderQty = 0;
SQL: SELECT COUNT(ProductID) FROM ProductVendor WHERE OnOrderQty = 0
Database: works_cycles
Question: What is the highest profit on net for a product?
Evidence: profit on net = subtract(LastReceiptCost, StandardPrice)
SQL: SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY LastReceiptCost - StandardPrice DESC LIMIT 1
Database: works_cycles
Question: Which reviewer gives the biggest number of the highest rating?
Evidence: highest rating refers to MAX(Rating)
SQL: SELECT ReviewerName FROM ProductReview WHERE Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )
Database: works_cycles
Question: Which product gets the most reviews?
Evidence: most reviews refers to MAX(count(ProductID))


SQL: 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
Database: works_cycles
Question: Among the products that are purchased, how many of them have never received the highest rating?
Evidence: product that are purchased refers to MakeFlag = 0; never received highest rating refers to Rating! = 5


SQL: 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
Database: works_cycles
Question: What is the biggest amount of reviews a salable product gets?
Evidence: salable product refers to FinishedGoodsFlag = 1; biggest amount reviews refers to MAX(count(ProductID))
SQL: 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
Database: works_cycles
Question: Among the products that are both manufactured in house and salable, how many of them get over 10 reviews?
Evidence: manufactured in house refers to MakeFlag = 1; salable product refers to FinishedGoodsFlag = 1; over 10 reviews refers to count(comments)>10
SQL: 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
Database: works_cycles
Question: Please list the names of the products that get over 10 reviews and a salable.
Evidence: salable product refers to FinishedGoodsFlag = 1; over 10 reviews refers to count(comments)>10
SQL: 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
Database: works_cycles
Question: Please list the reviewers who have given the highest rating for a medium class, women's product.
Evidence: highest rating refers to Rating = 5; high class refers to Class = 'H'; men's product refers to Style = 'M'
SQL: 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
Database: works_cycles
Question: What is the class of the product with the most reviews?
Evidence: most review refers to MAX(count(comments)); high class refers to Class = 'H'; medium class refers to Class = 'M'; low class refers to Class = 'L'
SQL: 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
Database: works_cycles
Question: Please list the e-mails of the reviewers who have reviewed high class.
Evidence: high class refers to Class = 'H'; men's product refers to Style = 'M'
SQL: SELECT T1.EmailAddress FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Class = 'H'
Database: works_cycles
Question: Please list the names of the products that have over 3 price changes.
Evidence: over 3 price changes refers to count(ListPrice)>3
SQL: 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
Database: works_cycles
Question: What is the product description of Headset Ball Bearings?
Evidence: Headset Ball Bearings is name of a product
SQL: SELECT T1.Description FROM ProductDescription AS T1 INNER JOIN Product AS T2 WHERE T2.Name = 'Headset Ball Bearings' AND T1.productDescriptionID = T2.ProductID
Database: works_cycles
Question: What is the highest vendor's selling price for Hex Nut 5?
Evidence: vendor's selling price refers to StandardPrice
SQL: 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
Database: works_cycles
Question: Please list all the vendors' usual selling prices of the product Hex Nut 5.
Evidence: vendor's selling price refers to StandardPrice
SQL: 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
Database: works_cycles
Question: Among the vendors that sell the product Hex Nut 5, how many of them have a good credit rating?
Evidence: good credit rating refers to CreditRating between 1 and 3
SQL: 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
Database: works_cycles
Question: Please list the website purchasing links of the vendors from whom the product Hex Nut 5 can be purchased.
Evidence: website purchasing link refers to PurchasingWebServiceURL
SQL: 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'
Database: works_cycles
Question: Which vendor's selling price for Hex Nut 5 is the lowest, please give the vendor's name.
Evidence: vendor's selling price refers to StandardPrice; lowest selling price = MIN(StandardPrice)
SQL: 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
Database: works_cycles
Question: How many high-class products are sold by preferred vendors?
Evidence: preferred vendor refers to PreferredVendorStatus = 1; high class refers to Class = 'H'
SQL: 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'
Database: works_cycles
Question: Please give all the list prices of the product LL Fork.
Evidence: Hex Nut 5 is name of a product
SQL: SELECT T2.ListPrice FROM Product AS T1 INNER JOIN ProductListPriceHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'LL Fork'
Database: works_cycles
Question: Among the products from the mountain product line, how many of them are sold by over 2 vendors?
Evidence: mountain product line refers to ProductLine = 'M'; sold by over 5 vendors refers to count(Name)>5
SQL: 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
Database: works_cycles
Question: Among the products that get over at least 1 review, how many of them are from the mountain product line?
Evidence: mountain product line refers to ProductLine = 'M'
SQL: 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
Database: works_cycles
Question: Please list the email adresses of the reviewers who have given the lowest rating to the product HL Mountain Pedal.
Evidence: lowest rating refers to Rating = 1
SQL: 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
Database: works_cycles
Question: How many products that take more than 2 days to make are out of stock?
Evidence: take more than 2 days to make refers to DaysToManufacture>2; out of stock refers to OnOrderQty = 0 or OnOrderQty is null
SQL: 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
Database: works_cycles
Question: Please list the products that are out of stock and purchased in house.
Evidence: take more than 2 days to make refers to DaysToManufacture>2; out of stock refers to OnOrderQty = 0 or OnOrderQty is null; manufactured in house refers to MakeFlag = 1
SQL: 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)
Database: works_cycles
Question: Among the salable products from the mountain product line, how many of them have the most reviews?
Evidence: salable product refers to FinishedGoodsFlag = 1; mountain product line refers to ProductLine = 'M'
SQL: 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
Database: works_cycles
Question: What is the average selling price of different vendors of the product Hex Nut 5?
Evidence: average selling price = divide(sum(StandardPrice), count(BusinessEntityID))
SQL: 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'
Database: works_cycles
Question: What is the product that has the highest average rating from the mountain product line?
Evidence: mountain product line refers to ProductLine = 'M'; highest average rating = max(divide(sum(Rating), count(ProductReview)))
SQL: 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
Database: works_cycles
Question: Please list the top 3 house-manufactured products with the highest average rating.
Evidence: home manufactured refers to MakeFlag = 1; average rating = divide(sum(Rating), count(ProductReview))
SQL: 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
Database: works_cycles
Question: List all the non-sales employees in ascending order of its business entitty ID.
Evidence: non-sales employee refers to PersonType = 'EM'
SQL: SELECT FirstName, LastName FROM Person WHERE PersonType = 'EM' ORDER BY BusinessEntityID
Database: works_cycles
Question: Name all person in the individual retail whose last name is 'Anderson'.
Evidence: person in the individual retail refers to PersonType = 'IN'
SQL: SELECT FirstName, MiddleName, LastName FROM Person WHERE LastName = 'Anderson' AND PersonType = 'IN'
Database: works_cycles
Question: List the name of employees who had left the company? When were they hired?
Evidence: employee that has left the company refers to EndDate is not null
SQL: SELECT T1.FirstName, T1.LastName, T2.HireDate 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.EndDate IS NOT NULL
Database: works_cycles
Question: Name all salaried employee who are hired in 2007 and later.
Evidence: salaried employee refers to SalariedFlag = 1; hired in 2007 and later refers to year(HireDate)> = 2007
SQL: 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
Database: works_cycles
Question: List the name of married employees with less than 20 vacation hours.
Evidence: married employee refers to MaritalStatus = 'M'; less than 20 vacation hours refers to VacationHours<20
SQL: 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