id
int64
0
9.43k
db_id
stringclasses
69 values
schema
stringclasses
69 values
question
stringlengths
24
325
output
stringlengths
23
804
evidence
stringlengths
0
673
filtered_schema
listlengths
0
16
7,300
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the products that get over at least 1 review, how many of them are from the mountain product line?
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
mountain product line refers to ProductLine = 'M'
[ "Product.ProductID", "Product.ProductLine", "ProductReview.ProductID", "ProductReview.ProductReviewID" ]
7,301
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list the email adresses of the reviewers who have given the lowest rating to the product HL Mountain Pedal.
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
lowest rating refers to Rating = 1
[ "Product.Name", "Product.ProductID", "ProductReview.EmailAddress", "ProductReview.ProductID", "ProductReview.Rating" ]
7,302
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many products that take more than 2 days to make are out of stock?
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
take more than 2 days to make refers to DaysToManufacture>2; out of stock refers to OnOrderQty = 0 or OnOrderQty is null
[ "Product.ProductID", "ProductVendor.OnOrderQty", "ProductVendor.ProductID" ]
7,303
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list the products that are out of stock and purchased in house.
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)
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
[ "Product.MakeFlag", "Product.Name", "Product.ProductID", "ProductVendor.OnOrderQty", "ProductVendor.ProductID" ]
7,304
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the salable products from the mountain product line, how many of them have the most reviews?
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
salable product refers to FinishedGoodsFlag = 1; mountain product line refers to ProductLine = 'M'
[ "Product.FinishedGoodsFlag", "Product.ProductID", "Product.ProductLine", "ProductReview.ProductID", "ProductReview.ProductReviewID" ]
7,305
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the average selling price of different vendors of the product Hex Nut 5?
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'
average selling price = divide(sum(StandardPrice), count(BusinessEntityID))
[ "Product.Name", "Product.ProductID", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "ProductVendor.StandardPrice" ]
7,306
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the product that has the highest average rating from the mountain product line?
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
mountain product line refers to ProductLine = 'M'; highest average rating = max(divide(sum(Rating), count(ProductReview)))
[ "Product.Name", "Product.ProductID", "Product.ProductLine", "ProductReview.ProductID", "ProductReview.Rating" ]
7,307
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list the top 3 house-manufactured products with the highest average rating.
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
home manufactured refers to MakeFlag = 1; average rating = divide(sum(Rating), count(ProductReview))
[ "Product.MakeFlag", "Product.Name", "Product.ProductID", "ProductReview.ProductID", "ProductReview.Rating" ]
7,308
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List all the non-sales employees in ascending order of its business entitty ID.
SELECT FirstName, LastName FROM Person WHERE PersonType = 'EM' ORDER BY BusinessEntityID
non-sales employee refers to PersonType = 'EM'
[ "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.PersonType" ]
7,309
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name all person in the individual retail whose last name is 'Anderson'.
SELECT FirstName, MiddleName, LastName FROM Person WHERE LastName = 'Anderson' AND PersonType = 'IN'
person in the individual retail refers to PersonType = 'IN'
[ "Person.FirstName", "Person.LastName", "Person.MiddleName", "Person.PersonType" ]
7,310
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List the name of employees who had left the company? When were they hired?
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
employee that has left the company refers to EndDate is not null
[ "Employee.BusinessEntityID", "Employee.HireDate", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.EndDate", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,311
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name all salaried employee who are hired in 2007 and later.
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
salaried employee refers to SalariedFlag = 1; hired in 2007 and later refers to year(HireDate)> = 2007
[ "Employee.BusinessEntityID", "Employee.HireDate", "Employee.SalariedFlag", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,312
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List the name of married employees with less than 20 vacation hours.
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
married employee refers to MaritalStatus = 'M'; less than 20 vacation hours refers to VacationHours<20
[ "Employee.BusinessEntityID", "Employee.MaritalStatus", "Employee.VacationHours", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,313
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name the oldest employee who is working on night shift. How old is the employee?
SELECT T1.FirstName, T1.LastName , STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate) FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.ShiftId = 3 ORDER BY STRFTIME('%Y', C...
working on night shift refers to ShiftID = 3; oldest employee refers to min(BirthDate); age = 2022-year(BirthDate)+1
[ "Employee.BusinessEntityID", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.ShiftId", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,314
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List all staff in the Shipping and Receiving department who are hired in 2009.
SELECT T1.FirstName, T1.LastName FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID WHERE STRFTIME('%Y', T2.HireDate) = '2009' AN...
hired in 2009 refers to year(HireDate) = 2009
[ "Department.DepartmentID", "Department.Name", "Employee.BusinessEntityID", "Employee.HireDate", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.DepartmentID", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,315
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the job title of the oldest employee in the company? In which department is he in?
SELECT T2.JobTitle, T4.Name FROM Person AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeeDepartmentHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN Department AS T4 ON T3.DepartmentID = T4.DepartmentID ORDER BY T2.HireDate LIMIT 1
oldest employee refers to min(BirthDate)
[ "Department.DepartmentID", "Department.Name", "Employee.BusinessEntityID", "Employee.HireDate", "Employee.JobTitle", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.DepartmentID", "Person.BusinessEntityID" ]
7,316
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Based on the lastet payrate of each employee, calculate the average hourly payrate for each department.
SELECT AVG(T1.Rate) FROM EmployeePayHistory AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T1.RateChangeDate = ( SELECT MAX(T1.RateChangeDate) FROM EmployeePayHistory AS T1 INNER JOIN Department AS T2 O...
latest payrate refers to max(RateChangeDate); average hourly payrate = divide(sum(Rate), count(BusinessEntityID)) for each DepartmentID
[ "Department.BusinessEntityID", "Department.DepartmentID", "EmployeePayHistory.BusinessEntityID", "EmployeePayHistory.Rate", "EmployeePayHistory.RateChangeDate" ]
7,317
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Other than the Chief Executive Officer, who is the employee who has the highest payrate? State the rate.
SELECT T2.FirstName, T2.LastName FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle NOT LIKE 'Chief Executive Officer' ORDER BY T1.Rate DESC LIMIT 1
other than the Chief Executive Officer refers to JobTitle! = 'Chief Executive Officer'; highest payrate refers to max(Rate)
[ "Employee.BusinessEntityID", "Employee.JobTitle", "EmployeePayHistory.BusinessEntityID", "EmployeePayHistory.Rate", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,318
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name the vendor who has the shortest average lead time for Product ID 319.
SELECT T1.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 319 ORDER BY T2.AverageLeadTime LIMIT 1
[ "ProductVendor.AverageLeadTime", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,319
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List all product name from Australia Bike Retailer order by product ID.
SELECT T3.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Product AS T3 ON T2.ProductID = T3.ProductID WHERE T1.Name = 'Australia Bike Retailer'
Australia Bike Retailer is name of vendor
[ "Product.Name", "Product.ProductID", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,320
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which vendor gives the best profit on net for product ID 342?
SELECT T1.Name FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.ProductID = 342 ORDER BY T2.LastReceiptCost - T2.StandardPrice DESC LIMIT 1
profit on net = subtract(LastReceiptCost, StandardPrice); best profit on net refers to max(subtract(LastReceiptCost, StandardPrice))
[ "ProductVendor.BusinessEntityID", "ProductVendor.LastReceiptCost", "ProductVendor.ProductID", "ProductVendor.StandardPrice", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,321
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the current payrate of Rob Walters? Calculate the percentage increment from his previous payrate.
SELECT T2.Rate , (MAX(T2.Rate) - MIN(T2.Rate)) * 100 / MAX(T2.Rate) FROM Person AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'Rob' AND T1.LastName = 'Walters'
current payrate refers to max(Rate); percentage increment = divide(subtract(max(Rate), min(Rate)), min(Rate))*100%
[ "EmployeePayHistory.BusinessEntityID", "EmployeePayHistory.Rate", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,322
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Calculate the average length of employment for employee working in the Research and Development deparment.
SELECT AVG(STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.HireDate)) FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T3.Name = 'Research and Development'
average length of employment = AVG(subtract(2022, year(HireDate)))
[ "Department.DepartmentID", "Department.Name", "Employee.BusinessEntityID", "Employee.HireDate", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.DepartmentID" ]
7,323
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the average age of employee in Adventure Works?
SELECT AVG(STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', BirthDate)) FROM Employee
average age = AVG(subtract(year(now), year(HireDate)))
[ "Employee.BirthDate" ]
7,324
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the employees in Adventure Works, calculate the percentage of them working as sales representatives.
SELECT CAST(SUM(CASE WHEN JobTitle = 'Sales Representative' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee
percentage of sales representatives = divide(count(JobTitle = 'Sales Representative'), count(JobTitle))*100%
[ "Employee.BusinessEntityID", "Employee.JobTitle" ]
7,325
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please provide contact details of all Marketing Managers. State their name and phone number.
SELECT T1.FirstName, T1.LastName, T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.JobTitle = 'Marketing Manager'
Marketing Manager is a job title
[ "Employee.BusinessEntityID", "Employee.JobTitle", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "PersonPhone.BusinessEntityID", "PersonPhone.PhoneNumber" ]
7,326
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List the person who owns a distinguish credt card.
SELECT T3.FirstName, T3.LastName FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.CardType = 'Distinguish'
distinguish credt card refers to cardType = 'Distinguish'
[ "CreditCard.CardType", "CreditCard.CreditCardID", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "PersonCreditCard.BusinessEntityID", "PersonCreditCard.CreditCardID" ]
7,327
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name the sales person for store Area Bike Accessories. Which territory is he / she in?
SELECT T4.Name FROM Store AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID INNER JOIN SalesTerritory AS T4 ON T2.TerritoryID = T4.TerritoryID WHERE T1.Name = 'Area Bike Accessories'
[ "Person.BusinessEntityID", "SalesPerson.BusinessEntityID", "SalesPerson.TerritoryID", "SalesTerritory.Name", "SalesTerritory.TerritoryID", "Store.Name", "Store.SalesPersonID" ]
7,328
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name all stores and its sales representative in France territory.
SELECT T3.Name, T4.FirstName, T4.LastName FROM SalesTerritory AS T1 INNER JOIN Customer AS T2 ON T1.TerritoryID = T2.TerritoryID INNER JOIN Store AS T3 ON T2.StoreID = T3.BusinessEntityID INNER JOIN Person AS T4 ON T2.PersonID = T4.BusinessEntityID WHERE T1.Name = 'France'
France territory refers to SalesTerritory.Name = 'France';
[ "Customer.PersonID", "Customer.StoreID", "Customer.TerritoryID", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "SalesTerritory.Name", "SalesTerritory.TerritoryID", "Store.BusinessEntityID", "Store.Name" ]
7,329
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Name all products that started selling in 2013. State its respective vendor's name.
SELECT T1.Name, T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE STRFTIME('%Y', T1.SellStartDate) = '2013'
Started selling in 2013 refers to year(SellStartDate) = 2013;
[ "Product.Name", "Product.ProductID", "Product.SellStartDate", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,330
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Names the Sales Representative with the highest year to date sales.
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.SalesYTD DESC LIMIT 1
Highest year to date sales refers to Max(SalesYTD);
[ "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.MiddleName", "SalesPerson.BusinessEntityID", "SalesPerson.SalesYTD" ]
7,331
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
List all product only MOQ of 1,000 and with standard cost more than 17.
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaxOrderQty = 1000 AND T2.StandardCost > 17
MOQ refers to minimum order quantity; MOQ of 1 refers to MinOrderQty = 1; standard cost more than 48 refers to StandardCost > 48;
[ "Product.Name", "Product.ProductID", "Product.StandardCost", "ProductVendor.BusinessEntityID", "ProductVendor.MaxOrderQty", "ProductVendor.ProductID", "Vendor.BusinessEntityID" ]
7,332
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Who is the oldest married male? State his job title.
SELECT T2.FirstName, T2.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate LIMIT 1
Male refers to Gender = 'M'; married refers to MaritalStatus = 'M'; oldest refers to Min(BirthDate);
[ "Employee.BirthDate", "Employee.BusinessEntityID", "Employee.Gender", "Employee.JobTitle", "Employee.MaritalStatus", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,333
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
State the vendor for product number WB-H098.
SELECT T3.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Vendor AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.ProductNumber = 'WB-H098'
[ "Product.ProductID", "Product.ProductNumber", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,334
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Find the vendor with the least average lead time for Product ID 348.
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ProductID = 348 ORDER BY T1.AverageLeadTime ASC LIMIT 1
[ "ProductVendor.AverageLeadTime", "ProductVendor.BusinessEntityID", "ProductVendor.ProductID", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,335
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
State the employee who are born in or after 1970 and with the least sick leave hour.
SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE STRFTIME('%Y', T1.BirthDate) > '1970' ORDER BY T1.SickLeaveHours LIMIT 1
born in or after 1970 refers to year(BirthDate) > = 1970;
[ "Employee.BirthDate", "Employee.BusinessEntityID", "Employee.SickLeaveHours", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName" ]
7,336
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Calculate the average age of employee in each department and state which department has the youngest employees.
SELECT STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.BirthDate) + 1 , T3.Name FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (BusinessEntityID) INNER JOIN Department AS T3 USING (DepartmentID) ORDER BY T1.BirthDate DESC LIMIT 1
Average = Divide(Sum(Substract(year(@today),year(BirthDate))),Count(BusinessEntityID) by each Department ID; youngest employee refers to Min(BirthDate);
[ "Department.Name", "Employee.BirthDate" ]
7,337
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please provide the IDs of any three AdventureWorks product subcategories.
SELECT DISTINCT ProductCategoryID FROM ProductSubcategory LIMIT 3
[ "ProductSubcategory.ProductCategoryID" ]
7,338
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the differences between the 288th salesperson's predicted annual sales and his or her actual sales thus far?
SELECT SalesYTD - SalesQuota FROM SalesPerson WHERE BusinessEntityID = 288
288th sales person refers to BusinessEntityID = 288; predited annual sales refers to SalesQuota; actual sales refers to SalesYTD; difference = Substract(SalesQuota(BusinessEntityID(288))), (SalesYTD(BusinessEntityID(288)));
[ "SalesPerson.BusinessEntityID", "SalesPerson.SalesQuota", "SalesPerson.SalesYTD" ]
7,339
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list three businesses with the lowest total sales from last year.
SELECT BusinessEntityID FROM SalesPerson ORDER BY SalesLastYear LIMIT 3
lowest total sales in last year refers to Min(SalesLastYear);
[ "SalesPerson.BusinessEntityID", "SalesPerson.SalesLastYear" ]
7,340
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which three sales regions have generated the most revenue thus far?
SELECT TerritoryID FROM SalesTerritory ORDER BY SalesYTD DESC LIMIT 3
revenue refers to SalesYTD; the most revenue refers to Max(SalesYTD);
[ "SalesTerritory.SalesYTD", "SalesTerritory.TerritoryID" ]
7,341
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What categories of offers qualify for group discounts for resellers?
SELECT Type FROM SpecialOffer WHERE Category = 'Reseller'
resellers refers to Category = 'Reseller';
[ "SpecialOffer.Category", "SpecialOffer.Type" ]
7,342
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the highest possible discount rate for 'Excess Inventory'?
SELECT DiscountPct FROM SpecialOffer WHERE Type = 'Excess Inventory' ORDER BY DiscountPct DESC LIMIT 1
excess inventory refers to Type = 'Excess Inventory'; highest possible discount refers to Max(DiscountPct);
[ "SpecialOffer.DiscountPct", "SpecialOffer.Type" ]
7,343
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the difference between the actual manufacturing cost of product number 818 and the estimated manufacturing cost?
SELECT PlannedCost - ActualCost FROM WorkOrderRouting WHERE ProductID = 818
product number 818 refers to ProductID = 818; estimated manufacturing cost refers PlannedCost; actual manufacturing cost refers to ActualCost; difference = Substract(PlannedCost(ProductID(818))),(ActualCost(ProductID(818)));
[ "WorkOrderRouting.ActualCost", "WorkOrderRouting.PlannedCost", "WorkOrderRouting.ProductID" ]
7,344
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many materials still need to be assembled and have a depth of 2 between each component and their parent product?
SELECT COUNT(*) FROM BillOfMaterials WHERE BOMLevel = 2 AND EndDate IS NULL
still need to be assembled means the assembly doesn't finish or still going on which refers to EndDate IS NULL; a depth of 2 refers to BOMLevel = 2;
[ "BillOfMaterials.BOMLevel", "BillOfMaterials.EndDate" ]
7,345
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many of the approved documents are confidential?
SELECT COUNT(DocumentNode) FROM Document WHERE Status = 2 AND DocumentSummary IS NULL
approved refers to Status = 2; confidential document refers to DocumentSummary is null;
[ "Document.DocumentNode", "Document.DocumentSummary", "Document.Status" ]
7,346
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the sales tax records charged by multiple types of tax?
SELECT SalesTaxRateID FROM SalesTaxRate WHERE Name LIKE '%+%'
multiple types of tax refers to Name like '%+%';
[ "SalesTaxRate.Name", "SalesTaxRate.SalesTaxRateID" ]
7,347
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which work order transaction number has the highest product quantity?
SELECT TransactionID FROM TransactionHistory WHERE TransactionType = 'W' ORDER BY Quantity DESC LIMIT 1
work order transaction refers to TransactionType = 'W';
[ "TransactionHistory.Quantity", "TransactionHistory.TransactionID", "TransactionHistory.TransactionType" ]
7,348
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list any 3 vendors that are not recommended by Adventure Works.
SELECT Name FROM Vendor WHERE PreferredVendorStatus = 0 LIMIT 3
not recommended refers to PreferredVendorStatus = 0;
[ "Vendor.Name", "Vendor.PreferredVendorStatus" ]
7,349
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many vendors does Adventure Works still work with but are not preferable?
SELECT COUNT(BusinessEntityID) FROM Vendor WHERE PreferredVendorStatus = 0 AND ActiveFlag = 1
not preferable refers to PreferredVendorStatus = 0; still work refers to ActiveFlag = 1;
[ "Vendor.ActiveFlag", "Vendor.BusinessEntityID", "Vendor.PreferredVendorStatus" ]
7,350
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many employees who began working in 2009 or later had night shifts?
SELECT COUNT(T1.BusinessEntityID) FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId WHERE T2.ShiftId = 3 AND STRFTIME('%Y', T2.StartTime) >= '2009'
began work in 2009 or later refers to StartDate> = 2009;
[ "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.ShiftId", "Shift.ShiftId", "Shift.StartTime" ]
7,351
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which department, altogether, has the most personnel who work the evening shift?
SELECT T3.Name FROM EmployeeDepartmentHistory AS T1 INNER JOIN Shift AS T2 ON T1.ShiftId = T2.ShiftId INNER JOIN Department AS T3 ON T1.DepartmentID = T3.DepartmentID WHERE T2.Name = 'Night' GROUP BY T3.Name ORDER BY COUNT(T1.BusinessEntityID) DESC LIMIT 1
evening shift also means night shift where Name = 'Night';most personnel in evening shift refers to Max(Count(Shift.ShiftID(Name = 'Night')));
[ "Department.DepartmentID", "Department.Name", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.DepartmentID", "EmployeeDepartmentHistory.ShiftId", "Shift.Name", "Shift.ShiftId" ]
7,352
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many shipments by truck were made?
SELECT COUNT(*) FROM ShipMethod AS T1 INNER JOIN SalesOrderHeader AS T2 USING (ShipMethodID) WHERE T1.Name = 'XRQ - TRUCK GROUND'
shipment by truck refers to Name = 'XRQ - TRUCK GROUND';
[ "ShipMethod.Name" ]
7,353
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the sales reasons for order 43718?
SELECT T2.Name FROM SalesOrderHeaderSalesReason AS T1 INNER JOIN SalesReason AS T2 ON T1.SalesReasonID = T2.SalesReasonID WHERE T1.SalesOrderID = 43718
order refers to SalesOrderID
[ "SalesOrderHeaderSalesReason.SalesOrderID", "SalesOrderHeaderSalesReason.SalesReasonID", "SalesReason.Name", "SalesReason.SalesReasonID" ]
7,354
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What bike subcategories are there?
SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN ProductCategory AS T2 ON T1.ProductCategoryID = T2.ProductCategoryID WHERE T2.name = 'Bikes'
bikes is product category
[ "ProductCategory.ProductCategoryID", "ProductCategory.name", "ProductSubcategory.Name", "ProductSubcategory.ProductCategoryID" ]
7,355
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which sales areas are expected to have the highest yearly sales quota?
SELECT T2.Name FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID GROUP BY T1.TerritoryID ORDER BY SUM(T1.SalesQuota) DESC LIMIT 1
highest yearly sales quota refers to Max(SalesQuota);
[ "SalesPerson.SalesQuota", "SalesPerson.TerritoryID", "SalesTerritory.Name", "SalesTerritory.TerritoryID" ]
7,356
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What goods were sold to customers in accordance with sales order number 43660?
SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.SalesOrderID = 43660
goods refers to products
[ "Product.Name", "Product.ProductID", "SalesOrderDetail.ProductID", "SalesOrderDetail.SalesOrderID" ]
7,357
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list the top 5 products with the most orders.
SELECT T1.Name FROM Product AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.Name ORDER BY SUM(T2.OrderQty) DESC LIMIT 0, 5
most order refers to Max(OrderQty);
[ "Product.Name", "Product.ProductID", "SalesOrderDetail.OrderQty", "SalesOrderDetail.ProductID" ]
7,358
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Where are the shelves where the down tube product was stored?
SELECT T2.Shelf FROM Product AS T1 INNER JOIN ProductInventory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Down Tube'
shelves refer to shelf; down tube is a product
[ "Product.Name", "Product.ProductID", "ProductInventory.ProductID", "ProductInventory.Shelf" ]
7,359
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which address type does "Fun Toys and Bikes" fall under?
SELECT T2.Name FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID INNER JOIN Store AS T3 ON T1.BusinessEntityID = T3.BusinessEntityID WHERE T3.Name = 'Fun Toys and Bikes'
Fun Toys and Bikes is name of a store
[ "AddressType.AddressTypeID", "AddressType.Name", "BusinessEntityAddress.AddressTypeID", "BusinessEntityAddress.BusinessEntityID", "Store.BusinessEntityID", "Store.Name" ]
7,360
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Who is the "Next-Door Bike Store" point of contact?
SELECT T1.Name FROM ContactType AS T1 INNER JOIN BusinessEntityContact AS T2 ON T1.ContactTypeID = T2.ContactTypeID INNER JOIN Store AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T3.Name = 'Next-Door Bike Store'
Next-Door Bike Store is name of a store
[ "BusinessEntityContact.BusinessEntityID", "BusinessEntityContact.ContactTypeID", "ContactType.ContactTypeID", "ContactType.Name", "Store.BusinessEntityID", "Store.Name" ]
7,361
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the order reference number for the "Mountain End Caps" product?
SELECT T2.ReferenceOrderID FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'Mountain End Caps'
Order Reference Number refers to ReferenceOrderID
[ "Product.Name", "Product.ProductID", "TransactionHistory.ProductID", "TransactionHistory.ReferenceOrderID" ]
7,362
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the 12th business's first line address?
SELECT T1.AddressLine1 FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T2.BusinessEntityID = 12
12th business refers to BusinessEntityID = 12;
[ "Address.AddressID", "Address.AddressLine1", "BusinessEntityAddress.AddressID", "BusinessEntityAddress.BusinessEntityID" ]
7,363
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Please list any three businesses with their IDs that are located in Dallas City.
SELECT T2.BusinessEntityID FROM Address AS T1 INNER JOIN BusinessEntityAddress AS T2 ON T1.AddressID = T2.AddressID WHERE T1.City = 'Dallas' LIMIT 3
business with ther ID refers to BusinessEntityID
[ "Address.AddressID", "Address.City", "BusinessEntityAddress.AddressID", "BusinessEntityAddress.BusinessEntityID" ]
7,364
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the name of the state that Racine belongs to?
SELECT T2.Name FROM Address AS T1 INNER JOIN StateProvince AS T2 ON T1.StateProvinceID = T2.StateProvinceID WHERE T1.City = 'Racine'
Racine is a city
[ "Address.City", "Address.StateProvinceID", "StateProvince.Name", "StateProvince.StateProvinceID" ]
7,365
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the difference in percentage between the product descriptions written in Arabic and Thai?
SELECT CAST(SUM(CASE WHEN T1.Name = 'Arabic' THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN T1.Name = 'Thai' THEN 1 ELSE 0 END) FROM Culture AS T1 INNER JOIN ProductModelProductDescriptionCulture AS T2 ON T1.CultureID = T2.CultureID
Arabic and Thai are language names refers to name = 'Arabic'and name = 'Thai'; Differencce in percentage = Subtract(((Count(CultureID(name = 'Arabic'))/Count(CultureID))*100),((Count(CultureID(name = 'Thai'))/Count(CultureID))*100)));
[ "Culture.CultureID", "Culture.Name", "ProductModelProductDescriptionCulture.CultureID" ]
7,366
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What percentage of businesses in the Northwest US have forecasted annual sales of above 300,000?
SELECT CAST(SUM(CASE WHEN T1.SalesQuota > 300000 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM SalesPerson AS T1 INNER JOIN SalesTerritory AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T2.CountryRegionCode = 'US' AND T2.Name = 'Northwest'
Northwest refers to Name = 'Northwest'; US refers to CountryRegionCode = 'US'; forecasted annual sales of above 300,000 refers to SalesQuota >300000; Percentage = Divide(Count(TerritoryID(SalesQuota >300000)),Count(TerritoryID))*100
[ "SalesPerson.BusinessEntityID", "SalesPerson.SalesQuota", "SalesPerson.TerritoryID", "SalesTerritory.CountryRegionCode", "SalesTerritory.Name", "SalesTerritory.TerritoryID" ]
7,367
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the Crankarm product's net profit?
SELECT T2.LastReceiptCost - T2.StandardPrice FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE '%Crankarm%'
net profit = Subtract(LastReceiptCost, StandardPrice);
[ "Product.Name", "Product.ProductID", "ProductVendor.LastReceiptCost", "ProductVendor.ProductID", "ProductVendor.StandardPrice" ]
7,368
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the name of the product with the almost highest review score?
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating DESC LIMIT 1 )
highest review score refers to Rating = 5;
[ "Product.Name", "Product.ProductID", "ProductReview.ProductID", "ProductReview.Rating" ]
7,369
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the company's second highest salary per hour for employees who are paid monthly?
SELECT Rate FROM EmployeePayHistory WHERE PayFrequency = 1 ORDER BY Rate DESC LIMIT 1, 1
salary received monthly refers to PayFrequency = 1; highest salary per hour refers to Max(Rate);
[ "EmployeePayHistory.PayFrequency", "EmployeePayHistory.Rate" ]
7,370
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many Vista cards expired before the year 2007?
SELECT COUNT(CreditCardID) FROM CreditCard WHERE CardType = 'Vista' AND ExpYear < 2007
Vista Card refers to CardType = 'Vista'; expire before the year 2007 refers to ExpYear< = 2006;
[ "CreditCard.CardType", "CreditCard.CreditCardID", "CreditCard.ExpYear" ]
7,371
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What time does the company's night shift begin? Indicate the answer in regular form.
SELECT StartTime FROM Shift WHERE Name = 'Night'
Night shift refers to Name = 'Night';
[ "Shift.Name", "Shift.StartTime" ]
7,372
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the weight in pounds of the style that is produced the most by the company? If there are multiple products sharing the same weight, indicate the name of each one of them and their corresponding weights.
SELECT Weight FROM Product WHERE WeightUnitMeasureCode = 'LB' GROUP BY Weight ORDER BY COUNT(Style) DESC LIMIT 1
weight in pounds refers to WeightUnitMeasureCode = 'LB';
[ "Product.Style", "Product.Weight", "Product.WeightUnitMeasureCode" ]
7,373
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which territory has the greatest difference in sales from previous year to this year? Indicate the difference, as well as the name and country of the region.
SELECT SalesLastYear - SalesYTD, Name, CountryRegionCode FROM SalesTerritory ORDER BY SalesLastYear - SalesYTD DESC LIMIT 1
greatest difference in sales from previous year to this year refers to Max(Subtract(SalesLastYear,SalesYTD));
[ "SalesTerritory.CountryRegionCode", "SalesTerritory.Name", "SalesTerritory.SalesLastYear", "SalesTerritory.SalesYTD" ]
7,374
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the names of the top 6 products that has the biggest size in centimeter and what are its reorder point?
SELECT Name, ReorderPoint FROM Product WHERE SizeUnitMeasureCode = 'CM' ORDER BY Size DESC LIMIT 6
in centimeter refers to SizeUnitMeasureCode = 'CM';
[ "Product.Name", "Product.ReorderPoint", "Product.Size", "Product.SizeUnitMeasureCode" ]
7,375
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How much is the amount to be paid by the company for the purchase order with the third highest freight amount?
SELECT TotalDue FROM PurchaseOrderHeader ORDER BY Freight DESC LIMIT 2, 1
amount to be paid refers to TotalDue;
[ "PurchaseOrderHeader.Freight", "PurchaseOrderHeader.TotalDue" ]
7,376
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What profit will the company gain if they sell 10 items of the product that has the lightest weight?
SELECT 10 * (ListPrice - StandardCost) FROM Product WHERE Weight IS NOT NULL ORDER BY Weight LIMIT 1
Lightest product refers to Min(Weight); profit if they sell 10 items refers to Subtract (ListPrice , StandardCost) *10;
[ "Product.ListPrice", "Product.StandardCost", "Product.Weight" ]
7,377
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How much is the tax amount of the purchase order with the biggest tax amount? Indicate the purchase order ID.
SELECT TaxAmt, PurchaseOrderID FROM PurchaseOrderHeader ORDER BY TaxAmt DESC LIMIT 1
tax amount refers to TaxAmt; biggest tax amount refers to MAX(TaxAmt);
[ "PurchaseOrderHeader.PurchaseOrderID", "PurchaseOrderHeader.TaxAmt" ]
7,378
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many person have a projected yearly sales of no more than 50,000?
SELECT COUNT(BusinessEntityID) FROM SalesPersonQuotaHistory WHERE SalesQuota < 500000
projected yearly sales refers to SalesQuota; SalesQuota< = 50000;
[ "SalesPersonQuotaHistory.BusinessEntityID", "SalesPersonQuotaHistory.SalesQuota" ]
7,379
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the employees who were born before 1969, what is the work shift of the 6th oldest employee?
SELECT T3.StartTime, T3.EndTime FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Shift AS T3 ON T2.ShiftId = T3.ShiftId WHERE STRFTIME('%Y', T1.BirthDate) < '1969' ORDER BY T1.BirthDate LIMIT 5, 1
oldest employee born before 1969 refers to year(BirthDate)<'1969';
[ "Employee.BirthDate", "Employee.BusinessEntityID", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.ShiftId", "Shift.EndTime", "Shift.ShiftId", "Shift.StartTime" ]
7,380
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which product allows the company to make the highest profit on a single item among those that are the fastest to manufacture? Indicate the rating of the product if there any.
SELECT T1.Name, T2.Rating FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.DaysToManufacture = ( SELECT DaysToManufacture FROM Product ORDER BY DaysToManufacture LIMIT 1 ) ORDER BY T1.ListPrice - T1.StandardCost DESC LIMIT 1
profit on a single item = SUBTRACT(ListPrice, StandardCost); length of time to manufacture refers to DaysToManufacture; fastest to manucature refers to MIN(DaysToManufacture);
[ "Product.DaysToManufacture", "Product.ListPrice", "Product.Name", "Product.ProductID", "Product.StandardCost", "ProductReview.ProductID", "ProductReview.Rating" ]
7,381
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the full names of the sales person whose bonuses are less than 1,000?
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM SalesPerson AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Bonus < 1000
full name = FirstName+MiddleName+LastName; Bonus<1000;
[ "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.MiddleName", "SalesPerson.Bonus", "SalesPerson.BusinessEntityID" ]
7,382
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
When did the Senior Tool Designer, who was 33 years old at the time he was hired, stopped working in the Engineering department?
SELECT T2.EndDate FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID WHERE T1.JobTitle = 'Senior Tool Designer' AND STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) = 33 AND T2.EndDate IS ...
Senior Tool Designer is a JobTitle; 33 years old at the time of hiring refers to SUBTRACT(year(HireDate)), (year(BirthDate)) = 33;
[ "Department.DepartmentID", "Employee.BirthDate", "Employee.BusinessEntityID", "Employee.HireDate", "Employee.JobTitle", "EmployeeDepartmentHistory.BusinessEntityID", "EmployeeDepartmentHistory.DepartmentID", "EmployeeDepartmentHistory.EndDate" ]
7,383
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the vendors with an average credit rating, what is the overall total due amount of purchases made by the company to the vendor that isn't preferrerd if another vendor is available?
SELECT SUM(T2.TotalDue) FROM Vendor AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.BusinessEntityID = T2.VendorID WHERE T1.CreditRating = 4 AND T1.PreferredVendorStatus = 0
average credit rating refers to CreditRating = 4;  vendor that isn't preferrerd if another vendor is available refers to PreferredVendorStatus = 0; SUM(TotalDue);
[ "PurchaseOrderHeader.TotalDue", "PurchaseOrderHeader.VendorID", "Vendor.BusinessEntityID", "Vendor.CreditRating", "Vendor.PreferredVendorStatus" ]
7,384
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which department has the most number of night shifts?
SELECT T3.Name FROM Shift AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.ShiftId = T2.ShiftId INNER JOIN Department AS T3 ON T2.DepartmentID = T3.DepartmentID GROUP BY T2.DepartmentID ORDER BY COUNT(T1.Name = 'Night') DESC LIMIT 1
most number of night shift = MAX(count(shift.Name = 'Night'))
[ "Department.DepartmentID", "Department.Name", "EmployeeDepartmentHistory.DepartmentID", "EmployeeDepartmentHistory.ShiftId", "Shift.Name", "Shift.ShiftId" ]
7,385
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How much profit can the company gained from selling two high class black Road Bikes with a size of 58?
SELECT 2 * (T1.ListPrice - T1.StandardCost) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'H' AND T1.Color = 'Black' AND T1.Size = 58 AND T2.Name = 'Road Bikes'
high class refers to Class = 'H"; road bikes is a name of product subcategory; profit = (MULTIPLY(SUBTRACT(ListPrice, StandardCost)), (2)));
[ "Product.Class", "Product.Color", "Product.ListPrice", "Product.ProductSubcategoryID", "Product.Size", "Product.StandardCost", "ProductSubcategory.Name", "ProductSubcategory.ProductSubcategoryID" ]
7,386
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the full names of the 10 youngest married male production technicians?
SELECT T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.JobTitle LIKE 'Production Technician%' AND T1.Gender = 'M' AND T1.MaritalStatus = 'M' ORDER BY T1.BirthDate DESC LIMIT 10
youngest refers to latest BirthDate; married refers to MaritalStatus = 'M'; production technician is a JobTitle; full name = FirstName+MiddleName+LastName;
[ "Employee.BirthDate", "Employee.BusinessEntityID", "Employee.Gender", "Employee.JobTitle", "Employee.MaritalStatus", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.MiddleName" ]
7,387
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Among the products with an average lead time of 60, which vendor has the highest profit on net? Indicate the credit rating of such vendor.
SELECT T2.Name, T2.CreditRating FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.AverageLeadTime = 60 ORDER BY T1.LastReceiptCost - T1.StandardPrice DESC LIMIT 1
profit on net = SUBTRACT(LastReceiptCost, StandardPrice);
[ "ProductVendor.AverageLeadTime", "ProductVendor.BusinessEntityID", "ProductVendor.LastReceiptCost", "ProductVendor.StandardPrice", "Vendor.BusinessEntityID", "Vendor.CreditRating", "Vendor.Name" ]
7,388
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the profit on net of the products that have exactly 200 maximum order quantity? Indicate the name of the vendors to which these products were purchased from.
SELECT T1.LastReceiptCost - T1.StandardPrice, T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaxOrderQty = 200
maximum orders refers to MaxOrderQty; MaxOrderQty = 200; profit on net = SUBTRACT(LastReceiptCost, StandardPrice);
[ "ProductVendor.BusinessEntityID", "ProductVendor.LastReceiptCost", "ProductVendor.MaxOrderQty", "ProductVendor.StandardPrice", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,389
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the full name of the non-sales employee who made the most number of rejected purchase orders?
SELECT T2.FirstName, T2.LastName FROM PurchaseOrderHeader AS T1 INNER JOIN Person AS T2 ON T1.EmployeeID = T2.BusinessEntityID WHERE T2.PersonType = 'EM' AND T1.Status = 3 GROUP BY T2.FirstName, T2.LastName ORDER BY COUNT(T1.PurchaseOrderID) DESC LIMIT 1
non-sales employee refers to PersonType = 'EM'; rejected purchase order refers to Status = 3;
[ "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.PersonType", "PurchaseOrderHeader.EmployeeID", "PurchaseOrderHeader.PurchaseOrderID", "PurchaseOrderHeader.Status" ]
7,390
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What are the names of the vendor with the second lowest minimum order quantity?
SELECT T2.Name FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.MaxOrderQty ASC LIMIT 1, 1
minimum order quantity refers to MinOrderQty;
[ "ProductVendor.BusinessEntityID", "ProductVendor.MaxOrderQty", "Vendor.BusinessEntityID", "Vendor.Name" ]
7,391
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How much are the minimum orders of the vendors that are no longer used by the company?
SELECT T2.MinOrderQty FROM Vendor AS T1 INNER JOIN ProductVendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.ActiveFlag = 0 ORDER BY T2.MinOrderQty LIMIT 1
vendors that are no longer used by the company refers to ActiveFlag = 0;
[ "ProductVendor.BusinessEntityID", "ProductVendor.MinOrderQty", "Vendor.ActiveFlag", "Vendor.BusinessEntityID" ]
7,392
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Of the employees whose vacation hours are no more than 10, what is the age of the oldest employee at the time he/she was hired? Indicate his/her full name.
SELECT STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate), T2.FirstName, T2.MiddleName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.VacationHours <= 10 ORDER BY STRFTIME('%Y', T1.HireDate) - STRFTIME('%Y', T1.BirthDate) DESC LIMIT 1
VacationHours<10; age at the time of being hired = SUBTRACT(year(HireDate), year(BirthDate)); full name = FirstName+MiddleName+LastName;
[ "Employee.BirthDate", "Employee.BusinessEntityID", "Employee.HireDate", "Employee.VacationHours", "Person.BusinessEntityID", "Person.FirstName", "Person.LastName", "Person.MiddleName" ]
7,393
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the primary type of all single female employees hired between 1/1/2008 to 12/31/2008?
SELECT T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'F' AND T1.MaritalStatus = 'S' AND STRFTIME('%Y-%m-%d', T1.HireDate) BETWEEN '2008-1-1' AND '2008-12-31' GROUP BY T2.PersonType ORDER BY COUNT(T2.PersonType) DESC LIMIT 1
primary type refers to PersonType; single refers to MaritalStatus = 'S"; female refers to Gender = 'F'; HireDate BETWEEN '2010-1-1'AND '2010-12-31';
[ "Employee.BusinessEntityID", "Employee.Gender", "Employee.HireDate", "Employee.MaritalStatus", "Person.BusinessEntityID", "Person.PersonType" ]
7,394
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the company's profit on the product that was rated second-highest by David?
SELECT T2.ListPrice - T2.StandardCost FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ReviewerName = 'David' ORDER BY T1.Rating DESC LIMIT 1
profit on net on a single product = SUBTRACT(ListPrice, StandardCost); second highest rating refers to Rating = 4; David is the ReviewerName;
[ "Product.ListPrice", "Product.ProductID", "Product.StandardCost", "ProductReview.ProductID", "ProductReview.Rating", "ProductReview.ReviewerName" ]
7,395
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which geographic area does the city with the second lowest tax rate belongs to? Indicate the name of the state or province as well.
SELECT T3.'Group', T2.Name FROM SalesTaxRate AS T1 INNER JOIN StateProvince AS T2 ON T1.StateProvinceID = T2.StateProvinceID INNER JOIN SalesTerritory AS T3 ON T2.TerritoryID = T3.TerritoryID ORDER BY T1.TaxRate LIMIT 1, 1
geographic area to which the city belong refers to Group;
[ "SalesTaxRate.StateProvinceID", "SalesTaxRate.TaxRate", "SalesTerritory.Group", "SalesTerritory.TerritoryID", "StateProvince.Name", "StateProvince.StateProvinceID", "StateProvince.TerritoryID" ]
7,396
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the average profit of all the low class universal road frames? Indicate how many variety of sizes are there and the available colors.
SELECT AVG(T1.ListPrice - T1.StandardCost), COUNT(DISTINCT T1.Size) , COUNT(DISTINCT T1.Style) FROM Product AS T1 INNER JOIN ProductSubcategory AS T2 ON T1.ProductSubcategoryID = T2.ProductSubcategoryID WHERE T1.Class = 'L' AND T2.Name = 'Road Frames' GROUP BY T1.Class, T1.Color
low class refers to Class = 'L'; universal refers to Style = 'U'; road frame is a name of product subcategory; average profit = AVG(SUBTRACT(ListPrice, StandardCost);
[ "Product.Class", "Product.Color", "Product.ListPrice", "Product.ProductSubcategoryID", "Product.Size", "Product.StandardCost", "Product.Style", "ProductSubcategory.Name", "ProductSubcategory.ProductSubcategoryID" ]
7,397
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
What is the discount percentage of "LL Road Frame Sale"?
SELECT DiscountPct FROM SpecialOffer WHERE Description = 'LL Road Frame Sale'
discount percentage refers to DiscountPct; LL Road Frame Sale is a description of special offer;
[ "SpecialOffer.Description", "SpecialOffer.DiscountPct" ]
7,398
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
How many discount are of the type "Excess Inventory"?
SELECT COUNT(SpecialOfferID) FROM SpecialOffer WHERE Type = 'Excess Inventory'
discount refers to DiscountPct; Excess Inventory is a type of special offer;
[ "SpecialOffer.SpecialOfferID", "SpecialOffer.Type" ]
7,399
works_cycles
CREATE TABLE sqlite_sequence(name,seq); CREATE TABLE CountryRegion ( CountryRegionCode TEXT not null primary key, Name TEXT not null unique, ModifiedDate DATETIME default current_timestamp not null ); CREATE TABLE Cultur...
Which seasonal discount had the highest discount percentage?
SELECT Description FROM SpecialOffer WHERE Type = 'Seasonal Discount' ORDER BY DiscountPct DESC LIMIT 1
seasonal discount is a type of special offer; discount percentage refers to DiscountPct; highest discount percentage refers to MAX(DiscountPct);
[ "SpecialOffer.Description", "SpecialOffer.DiscountPct", "SpecialOffer.Type" ]