Dataset Viewer
Auto-converted to Parquet Duplicate
split
stringclasses
2 values
db_id
stringclasses
21 values
question
stringlengths
23
325
evidence
stringlengths
0
591
mongodb_evidence
stringlengths
0
895
question_id
unknown
sample_id
stringlengths
7
10
SQL
stringlengths
29
1.45k
MQL
dict
train
works_cycles
What is the average standard cost of product number CA-1098?
Average cost = AVG(StandardCost)
Average cost = averaging productCostHistory.standardCost
6999
train_6999
SELECT AVG(T2.StandardCost) FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductNumber = 'CA-1098'
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "productNumber": "CA-1098" } }, { "$lookup": { "from": "productCostHistory", "localField": "_id", "foreignField": "productId", "as": "costHistory" } }, { "$un...
train
works_cycles
For all the products, list the product name and its corresponding start date for the current standard cost.
The current standard cost refers to EndDate is NULL
The current standard cost refers to productCostHistory.endDate is null
7000
train_7000
SELECT T1.Name, T2.StartDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.EndDate IS NULL
{ "collection": "productCostHistory", "aggregation_pipeline": [ { "$match": { "endDate": null } }, { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "productInfo" } }, { "$unwind": "$pr...
train
works_cycles
List the products whereby the standard cost is $80 more than previous standard cost in history.
SUBTRACT(product.StandardCost, CostHistory.StandardCost)>80
SUBTRACT(product.StandardCost, CostHistory.StandardCost)>80 refers to products.standardCost - productCostHistory.standardCost > 80
7001
train_7001
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.StandardCost - T2.StandardCost > 80 GROUP BY T1.Name
{ "collection": "productCostHistory", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "$product" }, { "$match": { "$expr": { ...
train
works_cycles
Name all products and total quantity for each item for shopping cart ID 14951.
7002
train_7002
SELECT T1.Name, T2.Quantity FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 14951
{ "collection": "shoppingCartItems", "aggregation_pipeline": [ { "$match": { "shoppingCartId": "14951" } }, { "$project": { "_id": 0, "Name": "$product.name", "Quantity": "$quantity" } } ] }
train
works_cycles
List the product name with more than 5 quantity in the shopping cart.
Product with more than 5 quantity refers to Quantity>5
Product with more than 5 quantity refers to shoppingCartItems.quantity > 5
7003
train_7003
SELECT T1.Name FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 5
{ "collection": "shoppingCartItems", "aggregation_pipeline": [ { "$match": { "quantity": { "$gt": 5 } } }, { "$project": { "_id": 0, "Name": "$product.name" } } ] }
train
works_cycles
For all the purchase order transactions, name all the products with low quality.
Low quality refers to the product's quality class, therefore Class = 'L'
Low quality refers to products.class = 'L'
7004
train_7004
SELECT DISTINCT T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'L' AND T2.TransactionType = 'P' ORDER BY T1.Name
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$match": { "transactionType": "P" } }, { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "...
train
works_cycles
Provide all the transactions whereby the quantiy is more than 10,000 pieces. State the product name and the selling price.
Quantity more than 10,000 pieces refers to Quantity>10000; selling price refers to ListPrice
Quantity more than 10,000 pieces refers to transactionHistory.quantity > 10000; selling price refers to products.listPrice
7005
train_7005
SELECT DISTINCT T1.Name, T1.ListPrice FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Quantity > 10000
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$match": { "quantity": { "$gt": 10000 } } }, { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, ...
train
works_cycles
Which is a high quality product but with the lowest transacted quantity?
High quality refers to the product's quality class, therefore Class = 'H'; the lowest transacted quantity refers to Quantity = 1
High quality refers to products.class = 'H'; the lowest transacted quantity refers to sorting by transactionHistory.quantity in ascending order, then taking the top result
7006
train_7006
SELECT T1.Name FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Class = 'H' ORDER BY T2.Quantity ASC LIMIT 1
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "$product" }, { "$match": { "product.class": "H" ...
train
works_cycles
How many transactions are there for product under the Mountain line?
The Mountain line refers to the product line, therefore ProductLine = 'M'
The Mountain line refers to products.productLine = 'M'
7007
train_7007
SELECT COUNT(T2.TransactionID) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'M'
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "$product" }, { "$match": { "product.productLine"...
train
works_cycles
How much would be the total sales profit for shopping cart ID 20621 ?
Sales profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost; Quantity)), where ShoppingCartID = '20621'
Sales profit = (shoppingCartItems.product.listPrice - products.standardCost) * shoppingCartItems.quantity, summed across all matching items; where shoppingCartItems.shoppingCartId = '20621'
7008
train_7008
SELECT SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN ShoppingCartItem AS T2 ON T1.ProductID = T2.ProductID WHERE T2.ShoppingCartID = 20621
{ "collection": "shoppingCartItems", "aggregation_pipeline": [ { "$match": { "shoppingCartId": "20621" } }, { "$lookup": { "from": "products", "localField": "product.productId", "foreignField": "_id", "as": "productDetails" } }, { ...
train
works_cycles
List all product names that are high in quality. Please also state its selling price.
High quality refers to the product's quality class, therefore Class = 'H'
High quality refers to products.class = 'H'
7009
train_7009
SELECT Name, ListPrice FROM Product WHERE Class = 'H'
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "class": "H" } }, { "$project": { "_id": 0, "name": 1, "listPrice": 1 } } ] }
train
works_cycles
Which product line has the most products that are salable?
Saleable product refers to FinishedGoodsFlag = 1
Saleable product refers to products.finishedGoodsFlag = true
7010
train_7010
SELECT ProductLine FROM Product WHERE FinishedGoodsFlag = 1 GROUP BY ProductLine ORDER BY COUNT(FinishedGoodsFlag) DESC LIMIT 1
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "finishedGoodsFlag": true } }, { "$group": { "_id": "$productLine", "count": { "$sum": 1 } } }, { "$sort": { "count": -1 } }, { ...
train
works_cycles
Provide details of review from reviewer whose name begin with letter 'J'. State the product ID, rating and comments.
reviewer whose name begin with letter 'J' = ReviewerName LIKE 'J%'
reviewer whose name begin with letter 'J' refers to productReviews.reviewer.name starting with 'J'
7011
train_7011
SELECT ProductID, Rating, Comments FROM ProductReview WHERE ReviewerName LIKE 'J%'
{ "collection": "productReviews", "aggregation_pipeline": [ { "$match": { "reviewer.name": { "$regularExpression": { "pattern": "^J", "options": "" } } } }, { "$project": { "_id": 0, "ProductID": { "$...
train
works_cycles
State the product name, product line, rating and the selling price of product with the lowest rating.
Product with the lowest rating refers to the rating given by the reviewer where Rating = 1
Product with the lowest rating refers to sorting by productReviews.rating in ascending order and taking the top result
7012
train_7012
SELECT T1.Name, T1.ProductLine, T2.Rating, T1.ListPrice FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.Rating ASC LIMIT 1
{ "collection": "productReviews", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "product.productId", "foreignField": "_id", "as": "productDetails" } }, { "$unwind": "$productDetails" }, { "$project": { "...
train
works_cycles
Calculate the profit of each products. List all products with more than $100 in profit.
Profit = AVG(SUBTRACT(ListPrice, StandardCost)>100
Profit = (products.listPrice minus products.standardCost) > 100
7013
train_7013
SELECT DISTINCT Name FROM Product WHERE ListPrice - StandardCost > 100
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "$expr": { "$gt": [ { "$subtract": [ "$listPrice", "$standardCost" ] }, 100 ] } } }, { ...
train
works_cycles
List down the product name, reviewer name, rating and comments for product under the road line.
The Road line refers to the product line, therefore ProductLine = 'R'
The Road line refers to the product line, therefore products.productLine = 'R'
7014
train_7014
SELECT T1.Name, T2.ReviewerName, T2.Rating, T2.Comments FROM Product AS T1 INNER JOIN ProductReview AS T2 USING (productID) WHERE T1.ProductLine = 'R'
{ "collection": "productReviews", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "product.productId", "foreignField": "_id", "as": "productDetails" } }, { "$unwind": "$productDetails" }, { "$match": { "pr...
train
works_cycles
How many people reviewed for product named HL Mountain Pedal? What is the average rating?
AVG(Rating) = DIVIDE(SUM(rating), COUNT(ReviewerName))
AVG(Rating) = sum of productReviews.rating divided by count of reviews
7015
train_7015
SELECT COUNT(T1.ProductID), AVG(T2.Rating) FROM Product AS T1 INNER JOIN ProductReview AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'HL Mountain Pedal'
{ "collection": "productReviews", "aggregation_pipeline": [ { "$match": { "product.name": "HL Mountain Pedal" } }, { "$group": { "_id": null, "review_count": { "$sum": 1 }, "avg_rating": { "$avg": "$rating" } } ...
train
works_cycles
List the purchase order whereby all received quantity were rejected? Name those product.
Rejected refers rejected product in which to RejectedQty = 1
Rejected refers to products where purchaseOrders.orderDetails.rejectedQty = purchaseOrders.orderDetails.receivedQty and purchaseOrders.orderDetails.rejectedQty β‰  0
7016
train_7016
SELECT T1.Name FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = T2.ReceivedQty AND T2.RejectedQty <> 0
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$match": { "orderDetails.rejectedQty": { "$ne": { "$numberDecimal": "0" } }, "$expr": { "$eq": [ { "$toDo...
train
works_cycles
Among all products without any rejected quantity, which product has the highest line total? State the product name and unit price.
Product without any rejected quantity refers to RejectedQty = 0
Product without any rejected quantity refers to purchaseOrders.orderDetails.rejectedQty = 0
7017
train_7017
SELECT T1.Name, T2.UnitPrice FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.RejectedQty = 0 ORDER BY T2.LineTotal DESC LIMIT 1
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$match": { "orderDetails.rejectedQty": { "$eq": { "$numberDecimal": "0" } } } }, { "$sort": { "orderDetails.lineTotal": -...
train
works_cycles
List all product names and its product line for all purchase order with order quantity of 5000 or more.
Purchase order with order quantity of 5000 or more refers to OrderQty> = 5000
Purchase order with order quantity of 5000 or more refers to purchaseOrders.orderDetails.orderQty >= 5000
7018
train_7018
SELECT T1.Name, T1.ProductLine FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderQty > 4999
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$match": { "orderDetails.orderQty": { "$gt": 4999 } } }, { "$lookup": { "from": "products", "localField": "orderDetails.product.product...
train
works_cycles
What is the total ordered quantity for products under the 'Touring' line?
The Touring line refers to the product line, therefore ProductLine = 'T'
The Touring line refers to products.productLine = 'T'
7019
train_7019
SELECT SUM(T2.OrderQty) FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductLine = 'T'
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$lookup": { "from": "products", "localField": "orderDetails.product.productId", "foreignField": "_id", "as": "productInfo" } }, { "$unwind": "$pr...
train
works_cycles
Among the low quality product, which product has the highest line total? List the product name and its line total?
Low quality refers to the product's quality class, therefore Class = 'L'
Low quality refers to products.class = 'L'
7020
train_7020
SELECT T1.Name, T2.LineTotal FROM Product AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.ProductID = T2.ProductID WHERE Class = 'L' ORDER BY OrderQty * UnitPrice DESC LIMIT 1
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$lookup": { "from": "products", "localField": "orderDetails.product.productId", "foreignField": "_id", "as": "productInfo" } }, { "$unwind": { ...
train
works_cycles
Which product has the highest profit on net? State the product name.
Profit on net = SUBTRACT(LastReceiptCost, StandardPrice)
Profit on net = vendors.preferredProducts.lastReceiptCost - vendors.preferredProducts.standardPrice
7021
train_7021
SELECT T1.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID ORDER BY T2.LastReceiptCost - T2.StandardPrice DESC LIMIT 1
{ "collection": "vendors", "aggregation_pipeline": [ { "$unwind": "$preferredProducts" }, { "$addFields": { "costDifference": { "$subtract": [ "$preferredProducts.lastReceiptCost", "$preferredProducts.standardPrice" ] } } ...
train
works_cycles
List all products with minimum order quantity of 100 and order them by product name in descending order.
miinimum order quantity refers to MinOrderQty = 100
miinimum order quantity refers to vendors.preferredProducts.minOrderQty = 100
7022
train_7022
SELECT DISTINCT T1.Name FROM Product AS T1 INNER JOIN ProductVendor AS T2 ON T1.ProductID = T2.ProductID WHERE T2.MinOrderQty = 100 ORDER BY T1.Name DESC
{ "collection": "vendors", "aggregation_pipeline": [ { "$unwind": "$preferredProducts" }, { "$match": { "preferredProducts.minOrderQty": 100 } }, { "$group": { "_id": "$preferredProducts.productName" } }, { "$sort": { "_id": -1 ...
train
works_cycles
What is the total profit all transactions with product ID 827?
Profit = MULTIPLY(SUBTRACT(ListPrice, StandardCost) Quantity))
Profit = (products.listPrice - products.standardCost) * transactionHistory.quantity
7024
train_7024
SELECT SUM((T1.ListPrice - T1.StandardCost) * T2.Quantity) FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.ProductID = 827
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$match": { "productId": "827" } }, { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "$pro...
train
works_cycles
Which currency pair's average exchange rate for the day is the highest?
currency pair refers to FromCurrencyCode/ToCurrencyCode
currency pair refers to currencyRates.fromCurrencyCode/currencyRates.toCurrencyCode
7025
train_7025
SELECT FromCurrencyCode, ToCurrencyCode FROM CurrencyRate ORDER BY AverageRate DESC LIMIT 1
{ "collection": "currencyRates", "aggregation_pipeline": [ { "$sort": { "averageRate": -1 } }, { "$limit": 1 }, { "$project": { "_id": 0, "fromCurrencyCode": 1, "toCurrencyCode": 1 } } ] }
train
works_cycles
How many products with the highest unit price were ordered?
number of products refers to OrderQty
number of products refers to purchaseOrders.orderDetails.orderQty
7026
train_7026
SELECT OrderQty FROM PurchaseOrderDetail ORDER BY UnitPrice DESC LIMIT 1
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$sort": { "orderDetails.unitPrice": -1 } }, { "$limit": 1 }, { "$project": { "_id": 0, "OrderQty": "$orderDetails.orderQty" } } ...
train
works_cycles
Between Northwest and Southeast of the United States, which territory one recorded the highest amount of sales last year?
United States refers to CountryRegionCode = 'US';
United States refers to salesTerritories.countryRegionCode = 'US';
7027
train_7027
SELECT Name FROM SalesTerritory WHERE CountryRegionCode = 'US' AND (Name = 'Northwest' OR Name = 'Southeast') ORDER BY SalesLastYear DESC LIMIT 1
{ "collection": "salesTerritories", "aggregation_pipeline": [ { "$match": { "countryRegionCode": "US", "$or": [ { "name": "Northwest" }, { "name": "Southeast" } ] } }, { "$sort": { "salesLas...
train
works_cycles
Which customer has the highest subtotal amount of sales orders whose assigned to the salesperson with the highest bonus?
highest subtotal amount of sales order refers to max(SubTotal);
highest subtotal amount of sales order refers to sorting by salesOrders.subtotal in descending order, then taking the top result;
7029
train_7029
SELECT T1.CustomerID FROM SalesOrderHeader AS T1 INNER JOIN SalesPerson AS T2 ON T1.SalesPersonID = T2.BusinessEntityID ORDER BY T1.SubTotal DESC LIMIT 1
{ "collection": "salesOrders", "aggregation_pipeline": [ { "$match": { "salesPerson.salesPersonId": { "$exists": true, "$ne": null } } }, { "$sort": { "subtotal": -1 } }, { "$limit": 1 }, { "$project": { ...
train
works_cycles
What is the total price of Sales Order ID 46625 with Volume Discount 11 to 14 and Product ID 716?
total price = multiply(UnitPrice, OrderQty);
total price refers to multiplying salesOrderDetails.unitPrice by salesOrderDetails.orderQty;
7030
train_7030
SELECT T2.UnitPrice * T2.OrderQty FROM SpecialOffer AS T1 INNER JOIN SalesOrderDetail AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID WHERE T1.Description = 'Volume Discount 11 to 14' AND T1.SpecialOfferID = 2 AND T2.ProductID = 716 AND T2.SalesOrderID = 46625
{ "collection": "salesOrderDetails", "aggregation_pipeline": [ { "$match": { "salesOrderId": "46625", "product.productId": "716", "specialOffer.specialOfferId": "2", "specialOffer.description": "Volume Discount 11 to 14" } }, { "$project": { "_id...
train
works_cycles
Of the products that has a reorder inventory point of no more than 600, how many manufactured in-house products that takes 1 day to manufacture with BOM Level 4 are there?
ReorderPoint<600; product is manufactured in-house refers to Makeflag = 1;
products.reorderPoint <= 600; product is manufactured in-house refers to products.makeFlag = true;
7031
train_7031
SELECT COUNT(T1.ProductID) FROM Product AS T1 INNER JOIN BillOfMaterials AS T2 ON T1.ProductID = T2.ProductAssemblyID WHERE T1.MakeFlag = 1 AND T1.DaysToManufacture = 1 AND T2.BOMLevel = 4 AND T1.ReorderPoint <= 600
{ "collection": "billOfMaterials", "aggregation_pipeline": [ { "$match": { "bomLevel": 4 } }, { "$lookup": { "from": "products", "localField": "productAssemblyId", "foreignField": "_id", "as": "product" } }, { "$unwind": { ...
train
works_cycles
What is the highest amount of bonus earned by the sales person in Canada?
Canada is name of a sales territory
Canada refers to salesTerritories.countryRegionCode
7032
train_7032
SELECT T2.Bonus FROM SalesTerritory AS T1 INNER JOIN SalesPerson AS T2 ON T1.TerritoryID = T2.TerritoryID WHERE T1.CountryRegionCode = 'CA' ORDER BY T2.SalesQuota DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "salesPerson": { "$exists": true } } }, { "$lookup": { "from": "salesTerritories", "localField": "salesPerson.territoryId", "foreignField": "_id", "as": "territo...
train
works_cycles
What are the names of the product that has the lowest rating?
lowest rating refers to Rating = 1;
lowest rating refers to productReviews.rating = 1;
7033
train_7033
SELECT T2.Name FROM ProductReview AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Rating = ( SELECT Rating FROM ProductReview ORDER BY Rating ASC LIMIT 1 )
{ "collection": "productReviews", "aggregation_pipeline": [ { "$group": { "_id": null, "minRating": { "$min": "$rating" }, "reviews": { "$push": "$$ROOT" } } }, { "$unwind": "$reviews" }, { "$match": { "$...
train
works_cycles
How many of the workers who started working in 2009 are from the Production Department?
StartDate BETWEEN '2009-01-01' AND '2009-12-31';
started working in 2009 refers to persons.employee.departmentHistory.startDate between 2009-01-01 and 2009-12-31
7034
train_7034
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID WHERE T2.StartDate >= '2009-01-01' AND T2.StartDate < '2010-01-01' AND T1.Name = 'Production'
{ "collection": "persons", "aggregation_pipeline": [ { "$unwind": "$employee.departmentHistory" }, { "$match": { "employee.departmentHistory.departmentName": "Production", "employee.departmentHistory.startDate": { "$gte": { "$date": "2009-01-01T00:00:00Z...
train
works_cycles
Who is the company's highest-paid single female employee? Include her full name and job title.
full name = FirstName+MiddleName+LastName; highest-paid refers to max(Rate); single refers to Status = 'S'; female refers to Gender = 'F';
full name = persons.firstName + persons.middleName + persons.lastName; highest-paid refers to sorting by persons.employee.payHistory.rate in descending order, then taking the top result; single refers to persons.employee.maritalStatus = 'S'; female refers to persons.employee.gender = 'F';
7035
train_7035
SELECT T3.FirstName, T3.MiddleName, T3.LastName, T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Person AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'F' ORDER BY T2.Rate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.gender": "F", "employee.maritalStatus": "S", "employee.payHistory": { "$exists": true, "$ne": [] } } }, { "$unwind": "$employee.payHistory" }, { ...
train
works_cycles
Who is the Vice President of Engineering and when did he join the company? Indicate his/her full name.
full name = FirstName+MiddleName+LastName; HiredDate refers to the date the person joins the company;
full name = persons.firstName+persons.middleName+persons.lastName; persons.employee.hireDate refers to the date the person joins the company;
7036
train_7036
SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.HireDate FROM Employee AS T1 INNER JOIN Person AS T2 USING (BusinessEntityID) WHERE T1.JobTitle = 'Vice President of Engineering'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.jobTitle": "Vice President of Engineering" } }, { "$project": { "_id": 0, "FirstName": "$firstName", "MiddleName": "$middleName", "LastName": "$lastName", "HireD...
train
works_cycles
How many active employees whose payrate is equal or below 30 per hour.
active employee refers to CurrentFlag = 1; Rate< = 30;
active employee refers to persons.employee.currentFlag = true; persons.employee.payHistory.rate <= 30;
7037
train_7037
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Rate <= 30
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$match": { "employee.payHistory.rate": { ...
train
works_cycles
Which department has a worker who just recently started working?
recently started working refers to latest StartDate;
recently started working refers to sorting by persons.employee.departmentHistory.startDate in descending order, then taking the top result;
7038
train_7038
SELECT T1.Name FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.DepartmentID = T2.DepartmentID ORDER BY T2.StartDate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$unwind": "$employee.departmentHistory" }, { "$sort": { "employee.departmentHistory.startDate": -1 } }, { "$limit": 1 }, { "$project": { "_id": 0, "Name": "$employee.departmentHi...
train
works_cycles
Which store sales person was reently hired? Indicate his/her full name and gender.
SC is an abbreviation for Store Contact; store contact person refers to PersonType = 'SC'; recently hired refers to latest StartDate;
SP is an abbreviation for Sales person; store sales person refers to persons.personType = 'SP'; recently hired refers to sorting by employee.hireDate in descending order, then taking the top result;
7039
train_7039
SELECT T2.FirstName, T2.MiddleName, T2.LastName, T1.Gender FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "SP" } }, { "$project": { "_id": 0, "FirstName": "$firstName", "MiddleName": "$middleName", "LastName": "$lastName", "Gender": "$employee.gender" } ...
train
works_cycles
How frequently do the employee with the least number of sick leave hours get paid?
least number of sick leave refers to min(SickLeaveHours); PayFrequency = 1 means β€˜Salary received monthly’; PayFrequency = 2 means β€˜Salary received biweekly';
least number of sick leave refers to sorting by persons.employee.sickLeaveHours in ascending order, then taking the top result; persons.employee.payHistory.payFrequency = 1 means 'Salary received monthly'; persons.employee.payHistory.payFrequency = 2 means 'Salary received biweekly';
7040
train_7040
SELECT T2.PayFrequency FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.SickLeaveHours ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$sort": { "employee.sickLeaveHours": 1 } }, { "$limit": 1 ...
train
works_cycles
Which job title has the lowest pay?
lowest pay refers to min(Rate);
lowest pay refers to sorting by employee.payHistory.rate in ascending order, then taking the top result
7041
train_7041
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeePayHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.Rate ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$sort": { "employee.payHistory.rate": 1 } }, { "$limit": 1 }, { ...
train
works_cycles
What is the total number of employees that worked in the Finance department?
7042
train_7042
SELECT COUNT(T2.BusinessEntityID) FROM Department AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 USING (DepartmentID) WHERE T1.Name = 'Finance'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.departmentHistory": { "$exists": true } } }, { "$unwind": "$employee.departmentHistory" }, { "$match": { "employee.departmentHistory.departmentName": "Finance" ...
train
works_cycles
What is the profit of the product with the highest list price and of the product with the lowest list price other than 0? Indicates the depth the component is from its parent.
profit = subtract(ListPrice, StandardCost); the depth the component from its parent refers to BOMLevel;
profit = subtract(products.listPrice, products.standardCost); the depth the component from its parent refers to billOfMaterials.bomLevel;
7043
train_7043
SELECT ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice DESC LIMIT 1 ) , ( SELECT ListPrice - StandardCost FROM Product WHERE ListPrice != 0 ORDER BY ListPrice LIMIT 1 )
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "listPrice": { "$ne": 0 } } }, { "$sort": { "listPrice": -1 } }, { "$group": { "_id": null, "products": { "$push": "$$ROOT" } ...
train
works_cycles
Among the companies to which Adventure Works Cycles purchases parts or other goods, what is the profit on net obtained from the vendor who has an above average credit rating? Kindly indicate each names of the vendor and the corresponding net profits.
above average credit rating refers to CreditRating = 3; profit on net = subtract(LastReceiptCost, StandardPrice);
above average credit rating refers to vendors.creditRating = 3; profit on net refers to vendors.preferredProducts.lastReceiptCost minus vendors.preferredProducts.standardPrice;
7044
train_7044
SELECT T2.Name, T1.LastReceiptCost - T1.StandardPrice FROM ProductVendor AS T1 INNER JOIN Vendor AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CreditRating = 3
{ "collection": "vendors", "aggregation_pipeline": [ { "$match": { "creditRating": 3 } }, { "$unwind": "$preferredProducts" }, { "$project": { "_id": 0, "Name": "$name", "T1.LastReceiptCost - T1.StandardPrice": { "$subtract": [ ...
train
works_cycles
How many accounts have an address that is too long?
address that is too long refers to AddressLine2! = null
address that is too long refers to addresses.addressLine2 not equal to empty string across persons, stores, and vendors collections
7045
train_7045
SELECT COUNT(*) FROM Address WHERE AddressLine2 <> ''
{ "collection": "persons", "aggregation_pipeline": [ { "$facet": { "persons": [ { "$limit": 1 }, { "$lookup": { "from": "persons", "pipeline": [ { "$unwind": "$addresses" ...
train
works_cycles
What is the postal code of the street address of the account that is latest updated?
account latest updated refers to year(ModifiedDate) = 2022 and month(ModifiedDate) = 10
account latest updated refers to sorting by addresses.modifiedDate in descending order across persons, stores, and vendors collections, then taking the top result
7046
train_7046
SELECT PostalCode FROM Address ORDER BY ModifiedDate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$unwind": "$addresses" }, { "$project": { "postalCode": "$addresses.postalCode", "modifiedDate": "$addresses.modifiedDate" } }, { "$unionWith": { "coll": "stores", "pipeline": [ ...
train
works_cycles
What is the longest assembly item duration for bicycles?
longest assembly item duration = max(subtract(EndDate,StartDate))
longest assembly item duration refers to sorting by (billOfMaterials.endDate - billOfMaterials.startDate) in descending order, then taking the top result
7047
train_7047
SELECT JULIANDAY(EndDate) - JULIANDAY(StartDate) FROM BillOfMaterials ORDER BY JULIANDAY(EndDate) - JULIANDAY(StartDate) DESC LIMIT 1
{ "collection": "billOfMaterials", "aggregation_pipeline": [ { "$project": { "_id": 0, "JULIANDAY(EndDate) - JULIANDAY(StartDate)": { "$cond": [ { "$ne": [ "$endDate", null ] }, { ...
train
works_cycles
How many assembly items for bicycles aren't finished?
assembly lines that are not finished refers to EndDate = null
assembly lines that are not finished refers to billOfMaterials.endDate = null
7048
train_7048
SELECT COUNT(BillOfMaterialsID) FROM BillOfMaterials WHERE EndDate IS NULL
{ "collection": "billOfMaterials", "aggregation_pipeline": [ { "$match": { "endDate": null } }, { "$count": "COUNT(BillOfMaterialsID)" } ] }
train
works_cycles
Please list the unit measure code of the component that is of the greatest need in quantity to create the assembly.
greatest need in quantity refers to max(PerAssemblyQty)
greatest need in quantity refers to sorting by perAssemblyQty in descending order, then taking the top result
7049
train_7049
SELECT UnitMeasureCode FROM BillOfMaterials ORDER BY PerAssemblyQty DESC LIMIT 1
{ "collection": "billOfMaterials", "aggregation_pipeline": [ { "$sort": { "perAssemblyQty": -1 } }, { "$limit": 1 }, { "$project": { "_id": 0, "unitMeasureCode": 1 } } ] }
train
works_cycles
How many product maintenance documents are private?
product maintenance documents are private refers to DocumentSummary = null
product maintenance documents are private refers to documents.documentSummary = null
7050
train_7050
SELECT COUNT(DocumentNode) FROM Document WHERE DocumentSummary IS NULL
{ "collection": "documents", "aggregation_pipeline": [ { "$match": { "documentSummary": null } }, { "$count": "COUNT(DocumentNode)" } ] }
train
works_cycles
Please list the titles of the documents that are pending approval.
documents pending approval refers to Status = 1
documents pending approval refers to documents.status = 1
7051
train_7051
SELECT Title FROM Document WHERE Status = 1
{ "collection": "documents", "aggregation_pipeline": [ { "$match": { "status": 1 } }, { "$project": { "Title": "$title", "_id": 0 } } ] }
train
works_cycles
Please list the job titles of the employees who has a document that has been approved.
document has been approved refers to Status = 2
document has been approved refers to documents.status = 2
7052
train_7052
SELECT DISTINCT T2.BusinessEntityID, T2.JobTitle FROM Document AS T1 INNER JOIN Employee AS T2 ON T1.Owner = T2.BusinessEntityID WHERE T1.Status = 2
{ "collection": "documents", "aggregation_pipeline": [ { "$match": { "status": 2 } }, { "$addFields": { "ownerStr": { "$toString": "$owner" } } }, { "$lookup": { "from": "persons", "localField": "ownerStr", "...
train
works_cycles
What is the pay frequency of the oldest employee?
oldest employee refers to min(BirthDate); PayFrequency = 1 refers to β€˜Salary received monthly’; PayFrequency = 2 refers to β€˜Salary received biweekly'
oldest employee refers to sorting by persons.employee.birthDate in ascending order, then taking the top result; persons.employee.payHistory.payFrequency = 1 refers to 'Salary received monthly'; persons.employee.payHistory.payFrequency = 2 refers to 'Salary received biweekly'
7053
train_7053
SELECT T1.PayFrequency FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.BirthDate ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$sort": { "employee.birthDate": 1 } }, { "$limit": 1 }, { ...
train
works_cycles
Among the employees whose pay frequencies are the highest, how many of them are married?
married refers to MaritalStatus = M; highest pay frequency refers to PayFrequency = 2
married refers to persons.employee.maritalStatus = 'M'; highest pay frequency refers to persons.employee.payHistory.payFrequency = 2
7054
train_7054
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.MaritalStatus = 'M' AND T1.PayFrequency = ( SELECT PayFrequency FROM EmployeePayHistory ORDER BY PayFrequency DESC LIMIT 1 )
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.maritalStatus": "M", "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$match": { "employee.payHistory.payFrequen...
train
works_cycles
For the employee who has been hired the latest, what is his or her pay rate?
hired the latest refers to max(HireDate)
hired the latest refers to sorting by persons.employee.hireDate in descending order, then taking the top result
7055
train_7055
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.HireDate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$sort": { "employee.hireDate": -1 } }, { "$limit": 1 }, { ...
train
works_cycles
Among the employees who have a pay rate of above 40, how many of them are male?
pay rate above 40 refers to Rate>40; male employee refers to Gender = M
pay rate above 40 refers to persons.employee.payHistory.rate > 40; male employee refers to persons.employee.gender = 'M'
7056
train_7056
SELECT SUM(CASE WHEN T2.Gender = 'M' THEN 1 ELSE 0 END) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate > 40
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$match": { "employee.payHistory.rate": { "$gt": 40 } } ...
train
works_cycles
What is the highest pay rate of the employees who are exempt from collective bargaining?
employee exempt from collective bargaining refers to SalariedFlag = 1; highest pay rate refers to max(Rate)
employee exempt from collective bargaining refers to persons.employee.salariedFlag = 1; highest pay rate refers to sorting by persons.employee.payHistory.rate in descending order, then taking the top result
7057
train_7057
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SalariedFlag = 1 ORDER BY T1.Rate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.salariedFlag": true, "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$project": { "_id": 0, "Rate": "$e...
train
works_cycles
For the employees who have the highest pay frequency, please list their vacation hours.
highest pay frequency refers to PayFrequency = 2
highest pay frequency refers to sorting by persons.employee.payHistory.rate in descending order, then taking the top result
7058
train_7058
SELECT T2.VacationHours FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.BusinessEntityID = ( SELECT BusinessEntityID FROM EmployeePayHistory ORDER BY Rate DESC LIMIT 1 )
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true }, "employee.payHistory": { "$exists": true, "$ne": [] } } }, { "$unwind": "$employee.payHistory" }, { "$sort": {...
train
works_cycles
What is the pay rate of the employee who has the longest vacation hours?
longest vacation hour refers to max(VacationHours)
longest vacation hour refers to sorting by persons.employee.vacationHours in descending order, then taking the top result
7059
train_7059
SELECT T1.Rate FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T2.VacationHours DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.vacationHours": { "$exists": true }, "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$addFields": { ...
train
works_cycles
How many employees with a pay rate of over 35 have more than 10 sick leave hours?
more than 10 sick leave hours refers to SickLeaveHours>10; pay rate over 35 refers to Rate>35;
more than 10 sick leave hours refers to persons.employee.sickLeaveHours > 10; pay rate over 35 refers to persons.employee.payHistory.rate > 35;
7060
train_7060
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.SickLeaveHours > 10 AND T1.Rate > 35
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.payHistory": { "$exists": true }, "employee.sickLeaveHours": { "$gt": 10 } } }, { "$unwind": "$employee.payHistory" }, { "$match": { "e...
train
works_cycles
Among the active male employees, how many of them are paid with the highest frequency?
active status of employees refers to CurrentFlag = 1; Male refers to Gender = 'M'; highest frequency refers to PayFrequency = 2;
active status of employees refers to persons.employee.currentFlag = true; Male refers to persons.employee.gender = 'M'; highest frequency refers to persons.employee.payHistory.payFrequency = 2;
7061
train_7061
SELECT COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.Gender = 'M' AND T1.PayFrequency = 2
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "employee.gender": "M" } }, { "$unwind": "$employee.payHistory" }, { "$match": { "employee.payHistory.payFrequency": 2 } }, { "$cou...
train
works_cycles
How many male employees have the job position of sales person?
Sales person refers to PersonType = 'SP'; Male refers to Gender = 'M';
Sales person refers to persons.personType = 'SP'; Male refers to persons.employee.gender = 'M';
7062
train_7062
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.PersonType = 'SP'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "SP", "employee.gender": "M" } }, { "$count": "count" } ] }
train
works_cycles
What is the job position of the oldest employee?
Oldest employee refers to Max ( Subtract((now())-BirthDate));
Oldest employee refers to sorting by persons.employee.birthDate in ascending order, then taking the top result;
7063
train_7063
SELECT T2.PersonType FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID ORDER BY T1.BirthDate ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true } } }, { "$sort": { "employee.birthDate": 1 } }, { "$limit": 1 }, { "$project": { "PersonType": "$personType", ...
train
works_cycles
What is the name style of the employee with the lowest pay rate?
lowest pay rate refers to Min(Rate);
lowest pay rate refers to sorting by persons.employee.payHistory.rate in ascending order, then taking the top result;
7064
train_7064
SELECT T2.NameStyle FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Rate IS NOT NULL ORDER BY T1.Rate ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.payHistory": { "$exists": true, "$ne": [] } } }, { "$unwind": "$employee.payHistory" }, { "$match": { "employee.payHistory.rate": { "$ne": nu...
train
works_cycles
Among the employees who are married, how many of them have a western name style?
married refers to MaritalStatus = 'M'; western name style refers to NameStyle = '0';
married refers to persons.employee.maritalStatus = 'M'; western name style refers to persons.nameStyle = 0;
7065
train_7065
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.MaritalStatus = 'M'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "nameStyle": 0, "employee.maritalStatus": "M" } }, { "$count": "count" } ] }
train
works_cycles
Among the employees who have more than 10 hours of sick leave, how many of them wish to receive e-mail promotions?
Contact does wish to receive e-mail promotions refers to EmailPromotion = (1,2); more than 10 hours of sick leave refer to SickLeaveHours >10;
Contact does wish to receive e-mail promotions refers to persons.emailPromotion = 1; more than 10 hours of sick leave refer to persons.employee.sickLeaveHours > 10;
7066
train_7066
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.SickLeaveHours > 10
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "emailPromotion": 1, "employee.sickLeaveHours": { "$gt": 10 } } }, { "$count": "count" } ] }
train
works_cycles
Please list the employees who have more than 20 vacations hours and wish to receive e-mail promotions.
Contact does wish to receive e-mail promotions refers to EmailPromotion = (1,2); more than 20 vacations hours refers to VacationHours>20
Contact does wish to receive e-mail promotions refers to persons.emailPromotion = 1; more than 20 vacations hours refers to persons.employee.vacationHours > 20
7067
train_7067
SELECT T1.BusinessEntityID FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.EmailPromotion = 1 AND T1.VacationHours > 20
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "emailPromotion": 1, "employee.vacationHours": { "$gt": 20 } } }, { "$project": { "_id": 1 } }, { "$project": { "BusinessEntityID": "$_id", "...
train
works_cycles
Please give the additional contact information of the oldest employee with the jod position of sales person.
Sales person refers to PersonType = 'SP'; oldest employee refers to Max (Subtract((now())-BirthDate));
Sales person refers to persons.personType = 'SP'; oldest employee refers to sorting by persons.employee.birthDate in ascending order, then taking the top result;
7068
train_7068
SELECT T2.AdditionalContactInfo FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE PersonType = 'SP' ORDER BY T1.BirthDate ASC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "SP", "employee.birthDate": { "$exists": true } } }, { "$sort": { "employee.birthDate": 1 } }, { "$limit": 1 }, { "$project": { ...
train
works_cycles
What is the first name of the male employee who has a western name style?
western name style refers to NameStyle = 0; Male refers to Gender = 'M';
western name style refers to persons.nameStyle = 0; Male refers to persons.employee.gender = 'M';
7069
train_7069
SELECT T2.FirstName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.NameStyle = 0 AND T1.Gender = 'M'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "nameStyle": 0, "employee.gender": "M" } }, { "$project": { "_id": 0, "FirstName": "$firstName" } } ] }
train
works_cycles
Among the active employees, how many of them have a courtesy title of "Mr"?
active status of employees refers to CurrentFlag = 1;
active status of employees refers to persons.employee.currentFlag = true;
7070
train_7070
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.Title = 'Mr.'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "title": "Mr." } }, { "$count": "count" } ] }
train
works_cycles
Please give the personal information of the married employee who has the highest pay rate.
married refers to MaritalStatus = 'M'; Highest pay rate refers to Max(Rate)
married refers to persons.employee.maritalStatus = 'M'; Highest pay rate refers to sorting by persons.employee.payHistory.rate in descending order, then taking the top result
7071
train_7071
SELECT T2.Demographics FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' ORDER BY T3.Rate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee": { "$exists": true }, "employee.maritalStatus": "M", "employee.payHistory": { "$exists": true, "$ne": [] } } }, { "$unwind": "$employee.pa...
train
works_cycles
What is the surname suffix of the employee who works as a store contact and has the longest sick leave hours?
store contact refers to PersonType = 'SC';
store contact refers to persons.personType = 'SC';
7072
train_7072
SELECT T2.Suffix FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.PersonType = 'SP' ORDER BY T1.SickLeaveHours DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "SP", "employee": { "$exists": true } } }, { "$sort": { "employee.sickLeaveHours": -1 } }, { "$limit": 1 }, { "$project": { ...
train
works_cycles
Among the married employees with the highest pay frequency, how many of them have an eastern name style?
married refers to MaritalStatus = 'M'; Eastern name style refers to NameStyle = 1;
married refers to persons.employee.maritalStatus = 'M'; Eastern name style refers to persons.nameStyle = 1;
7073
train_7073
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN EmployeePayHistory AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T1.MaritalStatus = 'M' AND T2.NameStyle = 1 AND T3.Rate = ( SELECT Rate FROM EmployeePayHistory ORDER BY Rate ...
{ "collection": "persons", "aggregation_pipeline": [ { "$facet": { "results": [ { "$match": { "employee": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, ...
train
works_cycles
How many active employees do not wish to receive e-mail promotions?
active status of employees refers to CurrentFlag = 1; the employee does not wish to receive an e-mail promotion refers to EmailPromotion = 0;
active status of employees refers to persons.employee.currentFlag = true; the employee does not wish to receive an e-mail promotion refers to persons.emailPromotion = 1;
7074
train_7074
SELECT COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.CurrentFlag = 1 AND T2.EmailPromotion = 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "emailPromotion": 1 } }, { "$count": "count" } ] }
train
works_cycles
Please list the credit card IDs of the employees who work as store contact.
store contact refers to PersonType = 'SC';
store contact refers to persons.personType = 'SC';
7075
train_7075
SELECT T2.CreditCardID FROM Person AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.PersonType = 'SC'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "SC" } }, { "$unwind": "$creditCards" }, { "$project": { "_id": 0, "CreditCardID": "$creditCards.cardId" } } ] }
train
works_cycles
How many vacation hours do the male employees have on average?
employee refers to PersonType = 'EM'; Male refers to Gender = 'M'; Average = Divide( SUM(VacationHours(PersonType = 'EM'& Gender = 'M')),Count(BusinessEntityID(PersonType = 'EM' & Gender = 'M')));
employee refers to persons.personType = 'EM'; Male refers to persons.employee.gender = 'M'; Average = (sum of persons.employee.vacationHours where personType = 'EM' and employee.gender = 'M') / (count of persons where personType = 'EM' and employee.gender = 'M');
7076
train_7076
SELECT CAST(SUM(T1.VacationHours) AS REAL) / COUNT(T1.BusinessEntityID) FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.Gender = 'M' AND T2.PersonType = 'EM'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "personType": "EM", "employee.gender": "M" } }, { "$group": { "_id": null, "totalVacationHours": { "$sum": "$employee.vacationHours" }, "count": { "$su...
train
works_cycles
Among the employees who are married and wish to receive e-mail promotions, how much higher is their highest pay rate from the average pay rate?
married refers to MaritalStatus = 'M'; Contact does wish to receive e-mail promotions from Adventure Works refers to EmailPromotion = 1; Average = Divide (Sum(Rate (MaritalStatus = 'M' & EmailPromotion = 1))), Count (BusinessEntityID (MaritalStatus = 'M' & EmailPromotion = 1)); MAX(Rate (MaritalStatus = 'M' & EmailProm...
married refers to persons.employee.maritalStatus = 'M'; Contact does wish to receive e-mail promotions from Adventure Works refers to persons.emailPromotion = 2; Average = (sum of persons.employee.payHistory.rate) / (count of pay history records); highest persons.employee.payHistory.rate minus Average;
7077
train_7077
SELECT MAX(T1.Rate) - SUM(T1.Rate) / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID INNER JOIN Employee AS T3 ON T2.BusinessEntityID = T3.BusinessEntityID WHERE T2.EmailPromotion = 2 AND T3.MaritalStatus = 'M'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "emailPromotion": 2, "employee.maritalStatus": "M", "employee.payHistory": { "$exists": true } } }, { "$unwind": "$employee.payHistory" }, { "$group": { "_...
train
works_cycles
Among the active employees with over 10 hours of sick leave, what is the percentage of the employees with over 20 vacation hours?
CurrentFlag = 1 refers to the active status of employees; Percentage = Divide (Count (BusinessEntityID (CurrentFlag = 1 & VacationHours >20 & SickLeaveHours > 10)), Count (BusinessEntityID (CurrentFlag = 1 & SickLeaveHours>10))) * 100;
CurrentFlag = 1 refers to persons.employee.currentFlag = true (active status of employees); Percentage = (count of persons where employee.currentFlag = true AND employee.vacationHours > 20 AND employee.sickLeaveHours > 10) / (count of persons where employee.currentFlag = true AND employee.sickLeaveHours > 10) * 100;
7079
train_7079
SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "employee.sickLeaveHours": { "$gt": 10 } } }, { "$unwind": "$employee.payHistory" }, { "$group": { "_id": null, "total": { ...
train
works_cycles
Average of the last receipt cost of the products whose average lead time is 60 days.
average = DIVIDE(SUM(lastreceiptcost), COUNT(OnorderQty)) where AverageLeadTime = 60
average = sum of vendors.preferredProducts.lastReceiptCost divided by count of matching products where vendors.preferredProducts.averageLeadTime = 60
7080
train_7080
SELECT SUM(LastReceiptCost) / COUNT(ProductID) FROM ProductVendor WHERE AverageLeadTime = 60
{ "collection": "vendors", "aggregation_pipeline": [ { "$unwind": "$preferredProducts" }, { "$match": { "preferredProducts.averageLeadTime": 60 } }, { "$group": { "_id": null, "sumLastReceiptCost": { "$sum": "$preferredProducts.lastReceip...
train
works_cycles
Average cost of purchase orders made during the first six months of 2012.
purchase orders refers to TransactionType = 'P'; first six months of 2012 refers to TransactionDate bewteen '2012-01-01'and '2012-06-30'; average = DIVIDE(ActualCost where TransactionType = 'P', count(TransactionID))
purchase orders refers to transactionHistoryArchive.transactionType = 'P'; first six months of 2012 refers to transactionHistoryArchive.transactionDate between '2012-01-01' and '2012-06-30'; average refers to sum of transactionHistoryArchive.actualCost divided by count of matching documents
7081
train_7081
SELECT CAST(SUM(ActualCost) AS REAL) / COUNT(TransactionID) FROM TransactionHistoryArchive WHERE TransactionType = 'P' AND TransactionDate >= '2012-01-01' AND TransactionDate < '2012-07-01'
{ "collection": "transactionHistoryArchive", "aggregation_pipeline": [ { "$match": { "transactionType": "P", "transactionDate": { "$gte": { "$date": "2012-01-01T00:00:00Z" }, "$lt": { "$date": "2012-07-01T00:00:00Z" } ...
train
works_cycles
What percentage of male employees hired throughout the years 2009 are married?
male refers to Gender = 'M'; hired throughout the years 2009 refers to Year(HireDate) = 2009; married refers to MaritalStatus = 'M'; percentage = DIVIDE(count(BusinessEntityID(Gender = 'M'& Year(HireDate) = '2009& MaritalStatus = 'M')), count(BusinessEntityID(Gender = 'M'& Year(HireDate) = 2009)))
male refers to persons.employee.gender = 'M'; hired throughout the years 2009 refers to persons.employee.hireDate within the year 2009; married refers to persons.employee.maritalStatus = 'M'; percentage refers to (count of (persons.employee.gender = 'M' AND persons.employee.hireDate is in 2009 AND persons.employee.mari...
7082
train_7082
SELECT CAST(SUM(CASE WHEN MaritalStatus = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(BusinessEntityID) FROM Employee WHERE SUBSTR(HireDate, 1, 4) = '2009' AND Gender = 'M'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.hireDate": { "$gte": { "$date": "2009-01-01T00:00:00Z" }, "$lt": { "$date": "2010-01-01T00:00:00Z" } }, "employee.gender": "M" } },...
train
works_cycles
What percentage of people named Mary who wants Receive Email promotions of AdventureWorks and selected partners are store contacts?
wants Receive Email promotions of AdventureWorks and selected partners refers to EmailPromotion = 2; store contact refers to PersonType = 'SC'; percentage = DIVIDE(count(BusinessEntityID(FirstName = 'Marry'&EmailPromotion = '2')),count(BusinessEntityID)))
wants Receive Email promotions of AdventureWorks and selected partners refers to persons.emailPromotion = 2; store contact refers to persons.personType = 'SC'; percentage = (count of persons where firstName = 'Mary' and emailPromotion = 2) / (count of persons where firstName = 'Mary' and personType = 'SC') * 100
7083
train_7083
SELECT CAST(SUM(CASE WHEN EmailPromotion = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / SUM(CASE WHEN PersonType = 'SC' THEN 1 ELSE 0 END) FROM Person WHERE FirstName = 'Mary'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "firstName": "Mary" } }, { "$group": { "_id": null, "emailPromotion2Count": { "$sum": { "$cond": [ { "$eq": [ "$emailPromotio...
train
works_cycles
List, by ProductID, all products whose profit, relative to the standard price, is negative.
Profit = SUBTRACT(StandardPrice, LastRecipeCost)
Profit = SUBTRACT(vendors.preferredProducts.standardPrice, vendors.preferredProducts.lastReceiptCost)
7084
train_7084
SELECT DISTINCT ProductID FROM ProductVendor WHERE StandardPrice - LastReceiptCost < 0
{ "collection": "vendors", "aggregation_pipeline": [ { "$unwind": "$preferredProducts" }, { "$match": { "$expr": { "$lt": [ { "$subtract": [ "$preferredProducts.standardPrice", "$preferredProducts.lastReceiptCost" ...
train
works_cycles
What is the average total due price of products with approved status?
approved refers to Status = 2 , average total due price = AVG( DIVIDE(TotalDue, SUM(Status = 2 )))
approved refers to purchaseOrders.status = 2; average total due price refers to averaging purchaseOrders.totalDue
7085
train_7085
SELECT SUM(TotalDue) / COUNT(TotalDue) FROM PurchaseOrderHeader WHERE Status = 2
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$match": { "status": 2 } }, { "$group": { "_id": null, "avg_total_due": { "$avg": "$totalDue" } } }, { "$project": { "_id": 0, "avg_total_due": 1...
train
works_cycles
What is the percentage, by number of sales order units, for orders with quantities not greater than 3 and a discount of 0.2?
quantities not greater than 3 refers to OrderQty<3; discount of 0.2 refers to UnitPriceDiscount = 0.2; percentage = DIVIDE(count(SalesOrderID(OrderQty<3 & UnitPriceDiscount = 0.2)), count(SalesOrderID))*100%
quantities not greater than 3 refers to salesOrderDetails.orderQty < 3; discount of 0.2 refers to salesOrderDetails.unitPriceDiscount = 0.2; percentage = (count of documents where salesOrderDetails.orderQty < 3 AND salesOrderDetails.unitPriceDiscount = 0.2) / (count of all documents in salesOrderDetails) * 100%
7086
train_7086
SELECT CAST(SUM(CASE WHEN OrderQty < 3 AND UnitPriceDiscount = 0.2 THEN 1 ELSE 0 END) AS REAL) / COUNT(SalesOrderID) FROM SalesOrderDetail
{ "collection": "salesOrderDetails", "aggregation_pipeline": [ { "$group": { "_id": null, "totalCount": { "$sum": 1 }, "matchingCount": { "$sum": { "$cond": [ { "$and": [ { "...
train
works_cycles
Lists all companies by BusinessEntityID that increased their current year sales by more than 60% over last year's sales and have a bonus greater than 3,000.
increased their current year sales by more than 60% refers to DIVIDE(SUBTRACT(SalesYTD, SalesLastYear),SalesLastYear)>0.6
increased their current year sales by more than 60% refers to (persons.salesPerson.salesYTD - persons.salesPerson.salesLastYear) / persons.salesPerson.salesLastYear > 0.6
7087
train_7087
SELECT BusinessEntityID FROM SalesPerson WHERE SalesYTD > SalesLastYear + SalesLastyear * 0.6 AND Bonus > 3000
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "salesPerson": { "$exists": true } } }, { "$match": { "$expr": { "$and": [ { "$gt": [ "$salesPerson.salesYTD", { ...
train
works_cycles
Add the number of businesses that indicate their home address as their address and those whose address corresponds to the shipping address.
their home address as their address refers to AddressTypeID = 2; address corresponds to the shipping address refers to AddressTypeID = 5
their home address as their address refers to addresses.addressType = 'Home'; address corresponds to the shipping address refers to addresses.addressType = 'Shipping'
7088
train_7088
SELECT SUM(CASE WHEN T2.Name = 'Home' THEN 1 ELSE 0 END) , SUM(CASE WHEN T2.Name = 'Shipping' THEN 1 ELSE 0 END) FROM BusinessEntityAddress AS T1 INNER JOIN AddressType AS T2 ON T1.AddressTypeID = T2.AddressTypeID
{ "collection": "persons", "aggregation_pipeline": [ { "$unionWith": { "coll": "stores", "pipeline": [] } }, { "$unionWith": { "coll": "vendors", "pipeline": [] } }, { "$match": { "addresses": { "$exists": true, ...
train
works_cycles
What company has a Colonial Voice card that expired in March 2005?
Colonial Voice card refers to CardType = 'ColonialVoice' ; expired in March 2005 refers to ExpMonth = 3, ExpYear = 2005
Colonial Voice card refers to persons.creditCards.cardType = 'ColonialVoice'; expired in March 2005 refers to persons.creditCards.expMonth = 3 and persons.creditCards.expYear = 2005
7090
train_7090
SELECT T2.BusinessEntityID FROM CreditCard AS T1 INNER JOIN PersonCreditCard AS T2 ON T1.CreditCardID = T2.CreditCardID WHERE T1.CardType = 'ColonialVoice' AND T1.ExpMonth = 3 AND T1.ExpYear = 2005
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "creditCards": { "$elemMatch": { "cardType": "ColonialVoice", "expMonth": 3, "expYear": 2005 } } } }, { "$project": { "BusinessEntityID": "...
train
works_cycles
Calculate the number of products if we add the products of the accessories and components categories.
7092
train_7092
SELECT COUNT(ProductID) FROM Product WHERE Name LIKE '%accessories %' OR Name LIKE '%components%'
{ "collection": "products", "aggregation_pipeline": [ { "$facet": { "matchedProducts": [ { "$match": { "$or": [ { "name": { "$regularExpression": { "pattern": "accessories ", ...
train
works_cycles
What is the job title of the newest employee in department 12?
newest employee refers to MAX(StartDate)
newest employee refers to sorting by employee.departmentHistory.startDate in descending order, then taking the top result
7093
train_7093
SELECT T1.JobTitle FROM Employee AS T1 INNER JOIN EmployeeDepartmentHistory AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.DepartmentID = 12 ORDER BY T2.StartDate DESC LIMIT 1
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.departmentHistory.departmentId": "12" } }, { "$unwind": "$employee.departmentHistory" }, { "$match": { "employee.departmentHistory.departmentId": "12" } }, { "...
train
works_cycles
List the first and last name of all unmarried male Production Supervisors.
unmarried refers to MaritalStatus = 'S', male refers to Gender = 'M', Production Supervisors is a job title
unmarried refers to persons.employee.maritalStatus = 'S'; male refers to persons.employee.gender = 'M'; Production Supervisors is a job title refers to persons.employee.jobTitle
7094
train_7094
SELECT T2.FirstName, T2.LastName FROM Employee AS T1 INNER JOIN Person AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.MaritalStatus = 'S' AND T1.Gender = 'M' AND T1.JobTitle LIKE 'Production Supervisor%'
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.maritalStatus": "S", "employee.gender": "M", "employee.jobTitle": { "$regularExpression": { "pattern": "^Production Supervisor", "options": "" } } ...
train
works_cycles
How many products are there if we add all those located in the Subassembly category?
located in the Subassembly category refers to Name = 'Subassembly'
located in the Subassembly category refers to productInventory.location.name = 'Subassembly'
7095
train_7095
SELECT COUNT(T1.LocationID) FROM Location AS T1 INNER JOIN ProductInventory AS T2 USING (LocationID) WHERE T1.Name = 'Subassembly'
{ "collection": "productInventory", "aggregation_pipeline": [ { "$match": { "location.name": "Subassembly" } }, { "$count": "count" } ] }
train
works_cycles
Sum the total number of products rejected for having a trim length that is too long.
number of product rejected refers to ScrapedQty; trim length that is too long refers to scrap reason where Name = 'Trim length too long'
number of product rejected refers to workOrders.scrappedQty; trim length that is too long refers to workOrders.scrapReason.name = 'Trim length too long'
7096
train_7096
SELECT SUM(T2.ScrappedQty) FROM ScrapReason AS T1 INNER JOIN WorkOrder AS T2 ON T1.ScrapReasonID = T2.ScrapReasonID WHERE T1.Name = 'Trim length too long'
{ "collection": "workOrders", "aggregation_pipeline": [ { "$match": { "scrapReason.name": "Trim length too long" } }, { "$group": { "_id": null, "total_scrapped": { "$sum": "$scrappedQty" } } }, { "$project": { "_id"...
train
works_cycles
Calculate the total quantity of purchased product that has been prepared by employee number 257 and is in pending shipment status.
employee number 257 refers to EmployeeID = 257; pending shipment status refers to Status = 3
employee number 257 refers to purchaseOrders.buyer.employeeId = 257; pending shipment status refers to purchaseOrders.status = 1
7097
train_7097
SELECT SUM(T2.OrderQty) FROM PurchaseOrderHeader AS T1 INNER JOIN PurchaseOrderDetail AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID WHERE T1.Status = 1
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$match": { "status": 1 } }, { "$unwind": "$orderDetails" }, { "$group": { "_id": null, "total_order_qty": { "$sum": "$orderDetails.orderQty" } } }, { ...
train
works_cycles
If we discount the products that do not have any type of offer, how many different products have been sold in an amount greater than 2 units per order?
do not have any type of offer refers to Description = 'No Discount'; sold in an amount greater than 2 refers to OrderQty>2
do not have any type of offer refers to salesOrderDetails.unitPriceDiscount = 0; sold in an amount greater than 2 refers to salesOrderDetails.orderQty > 2
7098
train_7098
SELECT COUNT(DISTINCT T1.ProductID) FROM SalesOrderDetail AS T1 INNER JOIN SpecialOfferProduct AS T2 ON T1.SpecialOfferID = T2.SpecialOfferID INNER JOIN SpecialOffer AS T3 ON T2.SpecialOfferID = T3.SpecialOfferID WHERE T1.OrderQty > 2 AND T1.UnitPriceDiscount = 0
{ "collection": "salesOrderDetails", "aggregation_pipeline": [ { "$match": { "orderQty": { "$gt": 2 }, "unitPriceDiscount": 0 } }, { "$group": { "_id": "$product.productId" } }, { "$count": "count" } ] }
train
works_cycles
What type of transaction was made with the only yellow product, size 62 and with a minimum inventory stock of 500 units?
yellow product refers to Color = 'Yellow'; minimum inventory stock of 500 units refers to SafetyStockLevel = 500
yellow product refers to products.color = 'Yellow'; minimum inventory stock of 500 units refers to products.safetyStockLevel = 500
7099
train_7099
SELECT DISTINCT T2.TransactionType FROM Product AS T1 INNER JOIN TransactionHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Size = 62 AND T1.Color = 'Yellow' AND T1.SafetyStockLevel = 500
{ "collection": "transactionHistory", "aggregation_pipeline": [ { "$lookup": { "from": "products", "localField": "productId", "foreignField": "_id", "as": "product" } }, { "$unwind": "$product" }, { "$match": { "product.size": "62",...
train
works_cycles
What is the name of the subcategory to which the gray product with the lowest safety stock level belongs?
gray is color of product
gray refers to products.color
7100
train_7100
SELECT T1.Name FROM ProductSubcategory AS T1 INNER JOIN Product AS T2 USING (ProductSubcategoryID) WHERE T2.Color = 'Grey' GROUP BY T1.Name
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "color": "Grey" } }, { "$group": { "_id": "$category.subcategoryName" } }, { "$project": { "Name": "$_id", "_id": 0 } }, { "$sort": { "Nam...
train
works_cycles
What is the product cost end date with the highest weight in grams?
in grams refers to WeightUnitMeasureCode = 'G'
in grams refers to products.weightUnitMeasure = 'G'
7101
train_7101
SELECT T2.EndDate FROM Product AS T1 INNER JOIN ProductCostHistory AS T2 ON T1.ProductID = T2.ProductID WHERE T1.WeightUnitMeasureCode = 'G' ORDER BY T1.Weight DESC LIMIT 1
{ "collection": "products", "aggregation_pipeline": [ { "$match": { "weightUnitMeasure": "G" } }, { "$sort": { "weight": -1 } }, { "$limit": 1 }, { "$lookup": { "from": "productCostHistory", "localField": "_id", ...
train
works_cycles
What is the percentage of the total products ordered were not rejected by Drill size?
rejected quantity refers to ScrappedQty; rejected by Drill size refers to Name in ('Drill size too small','Drill size too large'); percentage = DIVIDE(SUM(ScrappedQty) where Name in('Drill size too small','Drill size too large'), OrderQty)
rejected quantity refers to persons.employee.vacationHours > 20; rejected by Drill size refers to persons.employee.currentFlag = true and persons.employee.sickLeaveHours > 10; percentage = (count of persons.employee.payHistory records where vacationHours > 20) / (total count of persons.employee.payHistory records) * 10...
7102
train_7102
SELECT CAST(SUM(CASE WHEN T2.VacationHours > 20 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.BusinessEntityID) FROM EmployeePayHistory AS T1 INNER JOIN Employee AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T2.CurrentFlag = 1 AND T2.SickLeaveHours > 10
{ "collection": "persons", "aggregation_pipeline": [ { "$match": { "employee.currentFlag": true, "employee.sickLeaveHours": { "$gt": 10 } } }, { "$unwind": "$employee.payHistory" }, { "$group": { "_id": null, "totalCount":...
train
works_cycles
Calculate the average of the total ordered quantity of products purchased whose shipping method was Cargo Transport 5.
shipping method was Cargo Transport 5 refers to Name = 'Cargo Transport 5'; average = DIVIDE(SUM(OrderQty where Name = 'Cargo Transport 5'), COUNT(ShipMethodID))
shipping method was Cargo Transport 5 refers to purchaseOrders.shipMethod.shipMethodId = '5'; average = sum of purchaseOrders.orderDetails.orderQty where shipMethod.shipMethodId = '5', divided by count of all order detail items
7103
train_7103
SELECT CAST(SUM(IIF(T1.ShipMethodID = 5, T3.OrderQty, 0)) AS REAL) / COUNT(T3.ProductID) FROM ShipMethod AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.ShipMethodID = T2.ShipMethodID INNER JOIN PurchaseOrderDetail AS T3 ON T2.PurchaseOrderID = T3.PurchaseOrderID
{ "collection": "purchaseOrders", "aggregation_pipeline": [ { "$unwind": "$orderDetails" }, { "$group": { "_id": null, "sum_qty": { "$sum": { "$cond": [ { "$eq": [ "$shipMethod.shipMethodId", ...
End of preview. Expand in Data Studio

AptMQL-Bench

πŸ“„ Paper: AptMQL-Bench: From Text-to-SQL to Text-to-MQL via Access-Pattern Schema Design and Data-Preserving Migration  Β·  arXiv: coming soon

AptMQL-Bench is a benchmark for text-to-MQL β€” the task of translating human-readable requests into executable MongoDB Query Language (MQL) aggregation pipelines. It contains 21 document-oriented databases, 3,181 natural-language requests, and their associated gold MQL queries.

Most existing text-to-MQL resources are built by converting a relational benchmark mechanically: mapping each table to a collection one-to-one, or embedding tables along foreign keys. Both approaches derive the MongoDB schema from relational structure, which produces non-native designs, can silently drop rows during migration, and yields ground-truth queries that grow inefficient as the data scales. AptMQL-Bench takes a different route. It is produced by a conversion pipeline that treats schema design as a first-class step: each document schema is designed from the expected access patterns rather than from foreign-key topology, and every query is rewritten to be MongoDB-native. The pipeline is driven by coding agents with human-in-the-loop verification at each stage, so all 21 databases are migrated from their relational sources without data loss, and the ground-truth MQL stays efficient even as the databases grow large.

The benchmark is built on top of BIRD: it reuses BIRD's databases (10 from the train split, 11 from dev), its natural-language questions (kept verbatim, so intent is expressed independently of the query language), and its gold SQL β€” and adds, for each question, an equivalent MongoDB collection and aggregation pipeline validated for result-equivalence against the original SQL. AptMQL-Bench's databases are among the most structurally complex of comparable benchmarks, averaging 7.1 collections and roughly 218k documents per database, and its MQL queries are comparatively deep, averaging 4.0 aggregation stages at a nesting depth of 4.8. Text-to-MQL remains challenging: the strongest model evaluated, Claude Opus 4.5, reaches only 57.38% soft execution accuracy without external knowledge and 70.34% with it.

The benchmark ships two things:

  1. aptmqlbench_data.jsonl β€” 3,181 question / gold-SQL / gold-MQL examples (this is what the Hugging Face Dataset Viewer renders).
  2. databases/ β€” the underlying databases as mongodump archives (BSON), so you can restore them locally and actually execute the MQL.
count
Examples (aptmqlbench_data.jsonl) 3,181 (train: 1,758 Β· dev: 1,423)
Distinct databases (db_id) 21 (dev: 11 Β· train: 10)
Dump format mongodump BSON, created with MongoDB 8.2.7 / Database Tools 100.16.0

Repository layout

AptMQL-Bench/
β”œβ”€β”€ aptmqlbench_data.jsonl            # the benchmark: 3,181 question/SQL/MQL rows
β”œβ”€β”€ restore.sh                        # restores all dumps into a live MongoDB
β”œβ”€β”€ eval_script.py                    # result-equivalence (Soft-EX) checker
β”œβ”€β”€ requirements.txt                  # Python dependencies
β”œβ”€β”€ prompts/                          # prompts + design guidebook for the conversion pipeline
β”œβ”€β”€ ATTRIBUTION.md                    # source attribution & licensing
└── databases/
    β”œβ”€β”€ dev/                           # 11 databases
    β”‚   └── <db_id>/
    β”‚       β”œβ”€β”€ dump/                  # mongodump output β†’ restore with mongorestore
    β”‚       β”‚   β”œβ”€β”€ <collection>.bson
    β”‚       β”‚   β”œβ”€β”€ <collection>.metadata.json
    β”‚       β”‚   └── prelude.json
    β”‚       └── collections_description/
    β”‚           └── <collection>.jsonl # per-field schema documentation
    └── train/                         # 10 databases (same structure)

Databases

  • dev β€” california_schools, card_games, codebase_community, debit_card_specializing, european_football_2, financial, formula_1, student_club, superhero, thrombosis_prediction, toxicology
  • train β€” beer_factory, cs_semester, food_inspection_2, hockey, mondial_geo, professional_basketball, public_review_platform, restaurant, shooting, works_cycles

The aptmqlbench_data.jsonl schema

Each line is one example (JSON object):

Field Type Description
sample_id string Unique example id, e.g. train_6999
question_id string Original BIRD question id
split string train or dev
db_id string Target database β€” this is also the MongoDB database name after restore
question string The natural-language question
evidence string External knowledge/hint for the SQL formulation (from BIRD)
mongodb_evidence string The same hint restated for the MongoDB schema
SQL string Gold SQL over the original relational schema (kept for provenance/reference)
MQL object Gold MongoDB answer β€” the thing you execute (see below)

The MQL object has two keys:

{
  "collection": "products",
  "aggregation_pipeline": [
    {"$match": {"productNumber": "CA-1098"}},
    {"$lookup": {"from": "productCostHistory", "localField": "_id",
                 "foreignField": "productId", "as": "costHistory"}},
    {"$unwind": "$costHistory"},
    {"$group": {"_id": null, "avg_standard_cost": {"$avg": "$costHistory.standardCost"}}},
    {"$project": {"_id": 0, "avg_standard_cost": 1}}
  ]
}

Run it as db[collection].aggregate(aggregation_pipeline) against the database named db_id.

Schema documentation. Each collection also has a collections_description/<collection>.jsonl file. Every line documents one field: field_name, field_description, data_type, required, value_description. These are handy as schema context when prompting a model.


How to use the data

The end-to-end flow is: install MongoDB β†’ clone this repo β†’ restore the dumps β†’ load aptmqlbench_data.jsonl and run the gold MQL with PyMongo.

1. Install MongoDB

On macOS with Homebrew:

brew tap mongodb/brew
brew install mongodb-community          # the mongod server
brew install mongodb-database-tools     # mongorestore, mongoimport, ...
brew install mongosh                    # optional shell
brew services start mongodb-community   # start mongod on localhost:27017

On Windows or Linux, follow the official MongoDB installation guide.

You also need the Python client (used in step 4):

pip install pymongo

2. Clone the repo

The database dumps are stored with Git LFS, so install it before cloning:

brew install git-lfs # macOS if not already installed
git lfs install
git clone https://huggingface.co/datasets/giahy2507/AptMQL-Bench

3. Load the dumps into Live MongoDB

The repo ships a restore.sh script that restores every database (dev + train) into a live MongoDB server, each under its own db_id. Make sure MongoDB is running (default mongodb://localhost:27017), then from the repo root run:

cd AptMQL-Bench
bash restore.sh

Point it at a different server or repo location with environment variables if needed:

MONGO_URI="mongodb://user:pass@host:27017" DATA_ROOT="." bash restore.sh

Notes:

  • --db "$db_id" restores the flat *.bson files in dump/ as collections of a database with that exact name β€” this is what the db_id field in aptmqlbench_data.jsonl refers to.
  • --drop clears any existing collections first, so the loop is safe to re-run.
  • prelude.json just records the source server/tool versions; mongorestore reads it for information and it needs no special handling.
  • Restore a single database instead: mongorestore --drop --db california_schools AptMQL-Bench/databases/dev/california_schools/dump

Sanity-check what landed:

mongosh --quiet --eval 'db.getMongo().getDBNames()'          # list databases
mongosh california_schools --quiet --eval 'db.getCollectionNames()'

4. Load the JSONL and run the MQL (Python + PyMongo, Extended JSON)

Read aptmqlbench_data.jsonl, then parse each gold pipeline through MongoDB Extended JSON (EJSON) with bson.json_util before executing it. Extended JSON decoding turns constructs like {"$date": ...}, {"$oid": ...}, or {"$numberLong": ...} into the proper BSON types the server expects β€” routing every pipeline through json_util is safe even when a given pipeline is plain JSON.

from bson import json_util
from pymongo import MongoClient

client = MongoClient("mongodb://localhost:27017")

# Load the benchmark. json_util.loads parses each line as Extended JSON, so the
# whole row -- including the nested MQL -- is decoded into native BSON types.
with open("aptmqlbench_data.jsonl") as f:
    examples = [json_util.loads(line) for line in f]

def run_example(ex):
    """Execute the gold MQL for one benchmark row and return the result docs."""
    db = client[ex["db_id"]]                 # database name == db_id
    mql = ex["MQL"]
    collection = mql["collection"]
    pipeline = mql["aggregation_pipeline"]   # already Extended-JSON decoded above
    return list(db[collection].aggregate(pipeline))

ex = examples[0]
print(ex["db_id"], "|", ex["question"])
print("gold MQL result:", run_example(ex))

That is the core loop for evaluation: run your model's predicted pipeline the same way and compare its result set against run_example on the gold MQL. The repo ships eval_script.py, the result-equivalence checker used for scoring β€” its compare_fuzzy function implements the soft execution accuracy (Soft-EX) metric. Install its dependencies with pip install -r requirements.txt.


Citation

If you use AptMQL-Bench, please cite:

@article{aptmqlbench,
  title   = {AptMQL-Bench: From Text-to-SQL to Text-to-MQL via Access-Pattern
            Schema Design and Data-Preserving Migration},
  author  = {others},
  journal = {arXiv preprint},
  year    = {2026},
  url     = {}
}
Downloads last month
43