Dataset Viewer
Auto-converted to Parquet Duplicate
question_id
int64
1
4.04k
spider_question_id
int64
1
6.99k
db_id
stringclasses
139 values
difficulty
stringclasses
4 values
spider_gold_sql
stringlengths
18
507
question
stringlengths
19
224
query
stringlengths
16
997
gpt4 answer
stringlengths
1
997
deepseek answer
stringlengths
1
818
1
1
department_management
easy
SELECT count(*) FROM head WHERE age > 56
How many heads of the departments are older than 56 ?
db.head.aggregate([ { $match: { age: { $gt: 56 } } }, { $count: "total_heads_older_than_56" } ])
db.head.aggregate([ { $match: { age: { $gt: 56 } } }, { $count: "total_heads_older_than_56" } ])
.
2
2
department_management
medium
SELECT name , born_state , age FROM head ORDER BY age
List the name, born state and age of the heads of departments ordered by age.
db.head.find({}, {name: 1, born_state: 1, age: 1}).sort({age: 1})
db.head.find({}, {name: 1, born_state: 1, age: 1}).sort({age: 1})
.
3
3
department_management
medium
SELECT creation , name , budget_in_billions FROM department
List the creation year, name and budget of each department.
db.department.find({}, { Creation: 1, Name: 1, Budget_in_Billions: 1 })
db.department.find({}, { Creation: 1, Name: 1, Budget_in_Billions: 1 })
.
4
4
department_management
medium
SELECT max(budget_in_billions) , min(budget_in_billions) FROM department
What are the maximum and minimum budget of the departments?
db.department.aggregate([ { $group: { _id: null, maxBudget: { $max: "$Budget_in_Billions" }, minBudget: { $min: "$Budget_in_Billions" } } }, { $project: { maxBudget: 1, minBudget: 1 } } ])
db.department.aggregate([ { $group: { _id: null, maxBudget: { $max: "$Budget_in_Billions" }, minBudget: { $min: "$Budget_in_Billions" } } }, { $project: { maxBudget: 1, minBudget: 1 } } ])
db.department.aggregate([ { $group: { _id: null, maxBudget: { $max: "$Budget_in_Billions" }, minBudget: { $min: "$Budget_in_Billions" } } }, { $project: { maxBudget: 1, minBudget: 1 } } ])
5
5
department_management
easy
SELECT avg(num_employees) FROM department WHERE ranking BETWEEN 10 AND 15
What is the average number of employees of the departments whose rank is between 10 and 15?
db.department.aggregate([ { $match: { Ranking: { $gte: 10, $lte: 15 } } }, { $group: { _id: null, average: { $avg: "$Num_Employees" } } }, { $project: { avg: "$average" } } ])
db.department.aggregate([ { $match: { Ranking: { $gte: 10, $lte: 15 } } }, { $group: { _id: null, avgNumEmployees: { $avg: "$Num_Employees" } } }, { $project: { avgNumEmployees: 1 } } ])
db.department.aggregate([ { $match: { Ranking: { $gte: 10, $lte: 15 } } }, { $group: { _id: null, average: { $avg: "$Num_Employees" } } }, { $project: { avg: "$average" } } ])
6
6
department_management
easy
SELECT name FROM head WHERE born_state != 'California'
What are the names of the heads who are born outside the California state?
db.head.find({born_state: {$ne: 'California'}}, {name: 1})
db.head.find({ born_state: { $ne: "California" } }, { name: 1 })
db.head.find({born_state: {$ne: 'California'}}, {name: 1})
7
7
department_management
hard
SELECT DISTINCT T1.creation FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T3.born_state = 'Alabama'
What are the distinct creation years of the departments managed by a secretary born in state 'Alabama'?
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $unwind: "$management_info" }, { $lookup: { from: "head", localField: "management_info.head_ID", foreignField: "head_ID", as: "head_info" } }, { $unwind: "$head_info" }, { ...
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $unwind: "$management_info" }, { $lookup: { from: "head", localField: "management_info.head_ID", foreignField: "head_ID", as: "head_info" } }, { $unwind: "$head_info" }, { ...
.
8
8
department_management
easy
SELECT born_state FROM head GROUP BY born_state HAVING count(*) >= 3
What are the names of the states where at least 3 heads were born?
db.head.aggregate([ { $group: { _id: "$born_state", count: { $sum: 1 } } }, { $match: { count: { $gte: 3 } } }, { $project: { born_state: "$_id" } } ])
db.head.aggregate([ { $group: { _id: "$born_state", count: { $sum: 1 } } }, { $match: { count: { $gte: 3 } } }, { $project: { born_state: "$_id" } } ])
db.head.aggregate([ { $group: { _id: "$born_state", count: { $sum: 1 } } }, { $match: { count: { $gte: 3 } } }, { $project: { born_state: "$_id" } } ])
9
9
department_management
hard
SELECT creation FROM department GROUP BY creation ORDER BY count(*) DESC LIMIT 1
In which year were most departments established?
db.department.aggregate([ { $group: { _id: "$Creation", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { year: "$_id" } } ])
db.department.aggregate([ { $group: { _id: "$Creation", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { year: "$_id" } } ])
.
10
10
department_management
medium
SELECT T1.name , T1.num_employees FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id WHERE T2.temporary_acting = 'Yes'
Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes'?
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $unwind: "$management_info" }, { $match: { "management_info.temporary_acting": "Yes" } }, { $project: { name: "$Name", num_employees: "$Num_Employees" } } ])
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $unwind: "$management_info" }, { $match: { "management_info.temporary_acting": "Yes" } }, { $project: { name: "$Name", num_employees: "$Num_Employees" } } ])
.
11
12
department_management
extra
SELECT count(*) FROM department WHERE department_id NOT IN (SELECT department_id FROM management)
How many departments are led by heads who are not mentioned?
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $match: { "management_info": { $size: 0 } } }, { $count: "num_departments_with_no_heads" } ])
db.department.aggregate([ { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $match: { "management_info": { $size: 0 } } }, { $count: "num_departments_with_no_heads" } ])
.
12
13
department_management
medium
SELECT DISTINCT T1.age FROM management AS T2 JOIN head AS T1 ON T1.head_id = T2.head_id WHERE T2.temporary_acting = 'Yes'
What are the distinct ages of the heads who are acting?
db.management.aggregate([ { $match: { temporary_acting: "Yes" } }, { $lookup: { from: "head", localField: "head_ID", foreignField: "head_ID", as: "head_details" } }, { $unwind: "$head_details" }, { $group: { _id: "$head_details.age" } }, { $project: { age: "$_id" } } ])
db.management.aggregate([ { $match: { temporary_acting: "Yes" } }, { $lookup: { from: "head", localField: "head_ID", foreignField: "head_ID", as: "head_details" } }, { $unwind: "$head_details" }, { $group: { _id: "$head_details.age" } }, { $project: { age: "$_id" } } ])
.
13
14
department_management
extra
SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = T3.head_id WHERE T1.name = 'Treasury' INTERSECT SELECT T3.born_state FROM department AS T1 JOIN management AS T2 ON T1.department_id = T2.department_id JOIN head AS T3 ON T2.head_id = ...
List the states where both the secretary of 'Treasury' department and the secretary of 'Homeland Security' were born.
db.department.aggregate([ { $match: { $or: [ { Name: "Treasury" }, { Name: "Homeland Security" } ] } }, { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "dept_management" } }, { $unwind: "$dept_management" }, { $lookup: { from: "head", localField: "dept_management.head_ID...
db.department.aggregate([ { $match: { Name: {$in: ["Treasury", "Homeland Security"]} } }, { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "management_info" } }, { $unwind: "$management_info" }, { $lookup: { from: "head", localField: "management_info.head_ID", foreignFiel...
db.department.aggregate([ { $match: { $or: [ { Name: "Treasury" }, { Name: "Homeland Security" } ] } }, { $lookup: { from: "management", localField: "Department_ID", foreignField: "department_ID", as: "dept_management" } }, { $unwind: "$dept_management" }, { $lookup: { from: "head", localField: "dept_management.head_ID...
14
15
department_management
medium
SELECT T1.department_id , T1.name , count(*) FROM management AS T2 JOIN department AS T1 ON T1.department_id = T2.department_id GROUP BY T1.department_id HAVING count(*) > 1
Which department has more than 1 head at a time? List the id, name and the number of heads.
db.management.aggregate([ { $lookup: { from: "department", localField: "department_ID", foreignField: "Department_ID", as: "department_info" } }, { $unwind: "$department_info" }, { $group: { _id: "$department_ID", name: { $first: "$department_info.Name" }, count: { $sum: 1 } } }, { $match: { count: { $gt: 1 } } }, { $p...
db.management.aggregate([ { $group: { _id: "$department_ID", numberOfHeads: { $sum: 1 } } }, { $match: { numberOfHeads: { $gt: 1 } } }, { $lookup: { from: "department", localField: "_id", foreignField: "Department_ID", as: "department_info" } }, { $unwind: "$department_info" }, { $project: { department_id: "$_id", name...
db.management.aggregate([ { $lookup: { from: "department", localField: "department_ID", foreignField: "Department_ID", as: "department_info" } }, { $unwind: "$department_info" }, { $group: { _id: "$department_ID", name: { $first: "$department_info.Name" }, count: { $sum: 1 } } }, { $match: { count: { $gt: 1 } } }, { $p...
15
19
farm
easy
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
List the total number of horses on farms in ascending order.
db.farm.find({}, {Total_Horses: 1}).sort({Total_Horses: 1})
db.farm.find({}, {Total_Horses: 1}).sort({Total_Horses: 1})
db.farm.find({}, {Total_Horses: 1}).sort({Total_Horses: 1})
16
20
farm
easy
SELECT Total_Horses FROM farm ORDER BY Total_Horses ASC
What is the total horses record for each farm, sorted ascending?
db.farm.aggregate([ { $project: { Total_Horses: 1 } }, { $sort: { Total_Horses: 1 } } ])
db.farm.find({}, { Total_Horses: 1 }).sort({ Total_Horses: 1 })
db.farm.aggregate([ { $project: { Total_Horses: 1 } }, { $sort: { Total_Horses: 1 } } ])
17
21
farm
easy
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
What are the hosts of competitions whose theme is not 'Aliens'?
db.farm_competition.find({Theme: {$ne: 'Aliens'}}, {Hosts: 1})
db.farm_competition.find({ Theme: { $ne: 'Aliens' } }, { Hosts: 1 })
db.farm_competition.find({Theme: {$ne: 'Aliens'}}, {Hosts: 1})
18
22
farm
easy
SELECT Hosts FROM farm_competition WHERE Theme != 'Aliens'
Return the hosts of competitions for which the theme is not Aliens?
db.farm_competition.find({Theme: {$ne: 'Aliens'}}, {Hosts: 1})
db.farm_competition.find({ Theme: { $ne: "Aliens" } }, { Hosts: 1 })
db.farm_competition.find({Theme: {$ne: 'Aliens'}}, {Hosts: 1})
19
23
farm
easy
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
What are the themes of farm competitions sorted by year in ascending order?
db.farm_competition.find({}, { Theme: 1}).sort({Year: 1})
db.farm_competition.find({}, { Theme: 1 }).sort({ Year: 1 })
db.farm_competition.find({}, { Theme: 1}).sort({Year: 1})
20
24
farm
easy
SELECT Theme FROM farm_competition ORDER BY YEAR ASC
Return the themes of farm competitions, sorted by year ascending.
db.farm_competition.find({}, { Theme: 1}).sort({Year: 1})
db.farm_competition.find({}, { Theme: 1 }).sort({ Year: 1 })
db.farm_competition.find({}, { Theme: 1}).sort({Year: 1})
21
27
farm
medium
SELECT max(Cows) , min(Cows) FROM farm
What are the maximum and minimum number of cows across all farms.
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
22
28
farm
medium
SELECT max(Cows) , min(Cows) FROM farm
Return the maximum and minimum number of cows across all farms.
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
db.farm.aggregate([ { $group: { _id: null, maxCows: { $max: "$Cows" }, minCows: { $min: "$Cows" } } }, { $project: { maxCows: 1, minCows: 1 } } ])
23
31
farm
easy
SELECT Official_Name FROM city ORDER BY Population DESC
List official names of cities in descending order of population.
db.city.find({}, {Official_Name: 1}).sort({Population: -1})
db.city.find({}, {Official_Name: 1}).sort({Population: -1})
db.city.find({}, {Official_Name: 1}).sort({Population: -1})
24
32
farm
easy
SELECT Official_Name FROM city ORDER BY Population DESC
What are the official names of cities, ordered descending by population?
db.city.find({}, {Official_Name: 1}).sort({Population: -1})
db.city.find({}, { Official_Name: 1 }).sort({ Population: -1 })
db.city.find({}, {Official_Name: 1}).sort({Population: -1})
25
33
farm
medium
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
List the official name and status of the city with the largest population.
db.city.find({}, {Official_Name: 1, Status: 1}).sort({Population: -1}).limit(1)
db.city.find({}, { Official_Name: 1, Status: 1 }).sort({ Population: -1 }).limit(1)
db.city.find({}, {Official_Name: 1, Status: 1}).sort({Population: -1}).limit(1)
26
34
farm
medium
SELECT Official_Name , Status FROM city ORDER BY Population DESC LIMIT 1
What is the official name and status of the city with the most residents?
db.city.find({}, {Official_Name: 1, Status: 1}).sort({Population: -1}).limit(1)
db.city.find({}, { Official_Name: 1, Status: 1 }).sort({ Population: -1 }).limit(1)
db.city.find({}, {Official_Name: 1, Status: 1}).sort({Population: -1}).limit(1)
27
35
farm
medium
SELECT T2.Year , T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID
Show the years and the official names of the host cities of competitions.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "host_city_info" } }, { $unwind: "$host_city_info" }, { $project: { "_id": 0, "Year": "$host_city_info.Year", "Official_Name": 1 } } ])
.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "host_city_info" } }, { $unwind: "$host_city_info" }, { $project: { "_id": 0, "Year": "$host_city_info.Year", "Official_Name": 1 } } ])
28
37
farm
medium
SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1
Show the official names of the cities that have hosted more than one competition.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $match: { "competitions.1": { $exists: true } } }, { $project: { "_id": 0, "Official_Name": 1 } } ])
.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $match: { "competitions.1": { $exists: true } } }, { $project: { "_id": 0, "Official_Name": 1 } } ])
29
38
farm
medium
SELECT T1.Official_Name FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID HAVING COUNT(*) > 1
What are the official names of cities that have hosted more than one competition?
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $match: { "competitions.1": { $exists: true } } }, { $project: { Official_Name: 1 } } ])
.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $match: { "competitions.1": { $exists: true } } }, { $project: { Official_Name: 1 } } ])
30
39
farm
extra
SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
Show the status of the city that has hosted the greatest number of competitions.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $project: { Status: 1 } }, { $sort: { numCompetitions: -1 } }, { $limit: 1 } ])
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $project: { Status: 1, NumberOfCompetitions: { $size: "$competitions" } } }, { $sort: { NumberOfCompetitions: -1 } }, { $limit: 1 }, { $project: { Status: 1 }} ])
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $project: { Status: 1 } }, { $sort: { numCompetitions: -1 } }, { $limit: 1 } ])
31
40
farm
extra
SELECT T1.Status FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID GROUP BY T2.Host_city_ID ORDER BY COUNT(*) DESC LIMIT 1
What is the status of the city that has hosted the most competitions?
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $project: { Status: 1 } }, { $sort: { numCompetitions: -1 } }, { $limit: 1 } ])
.
db.city.aggregate([ { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $project: { Status: 1 } }, { $sort: { numCompetitions: -1 } }, { $limit: 1 } ])
32
41
farm
medium
SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000
Please show the themes of competitions with host cities having populations larger than 1000.
db.city.aggregate([ { $match: { Population: { $gt: 1000 } } }, { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $unwind: "$competitions" }, { $project: { Theme: "$competitions.Theme" } } ])
db.city.aggregate([ { $match: { Population: { $gt: 1000 } } }, { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $unwind: "$competitions" }, { $project: { Theme: "$competitions.Theme" } } ])
db.city.aggregate([ { $match: { Population: { $gt: 1000 } } }, { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $unwind: "$competitions" }, { $project: { Theme: "$competitions.Theme" } } ])
33
42
farm
medium
SELECT T2.Theme FROM city AS T1 JOIN farm_competition AS T2 ON T1.City_ID = T2.Host_city_ID WHERE T1.Population > 1000
What are the themes of competitions that have corresponding host cities with more than 1000 residents?
db.city.aggregate([ { $match: { Population: { $gt: 1000 } } }, { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $unwind: "$competitions" }, { $project: { Theme: "$competitions.Theme" } } ])
.
db.city.aggregate([ { $match: { Population: { $gt: 1000 } } }, { $lookup: { from: "farm_competition", localField: "City_ID", foreignField: "Host_city_ID", as: "competitions" } }, { $unwind: "$competitions" }, { $project: { Theme: "$competitions.Theme" } } ])
34
43
farm
medium
SELECT Status , avg(Population) FROM city GROUP BY Status
Please show the different statuses of cities and the average population of cities with each status.
db.city.aggregate([ { $group: { _id: "$Status", averagePopulation: { $avg: "$Population" } } } ])
db.city.aggregate([ { $group: { _id: "$Status", AveragePopulation: { $avg: "$Population" } } }, { $project: { Status: "$_id", AveragePopulation: 1 } } ])
db.city.aggregate([ { $group: { _id: "$Status", averagePopulation: { $avg: "$Population" } } } ])
35
44
farm
medium
SELECT Status , avg(Population) FROM city GROUP BY Status
What are the statuses and average populations of each city?
db.city.aggregate([ { $group: { _id: "$Status", averagePopulation: { $avg: "$Population" } } } ])
db.city.aggregate([ { $group: { _id: "$Status", AveragePopulation: { $avg: "$Population" } } }, { $project: { Status: "$_id", AveragePopulation: 1 } } ])
db.city.aggregate([ { $group: { _id: "$Status", averagePopulation: { $avg: "$Population" } } } ])
36
45
farm
medium
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Please show the different statuses, ordered by the number of cities that have each.
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { Status: "$_id"} } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { Status: "$_id" } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { Status: "$_id"} } ])
37
46
farm
medium
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) ASC
Return the different statuses of cities, ascending by frequency.
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { Status: "$_id" } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { _id: 1 } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: 1 } }, { $project: { Status: "$_id" } } ])
38
47
farm
hard
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
List the most common type of Status across cities.
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { Status: "$_id" } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { _id: 1 } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { Status: "$_id" } } ])
39
48
farm
hard
SELECT Status FROM city GROUP BY Status ORDER BY COUNT(*) DESC LIMIT 1
What is the most common status across all cities?
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { Status: "$_id" } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { Status: "$_id" } } ])
db.city.aggregate([ { $group: { _id: "$Status", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { Status: "$_id" } } ])
40
53
farm
medium
SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500
Find the official names of cities with population bigger than 1500 or smaller than 500.
db.city.find({$or: [{Population: {$gt: 1500}}, {Population: {$lt: 500}}]}, { Official_Name: 1})
db.city.find({$or: [{Population: {$gt: 1500}}, {Population: {$lt: 500}}]}, { Official_Name: 1})
.
41
54
farm
medium
SELECT Official_Name FROM city WHERE Population > 1500 OR Population < 500
What are the official names of cities that have population over 1500 or less than 500?
db.city.find( { $or: [ {Population: {$gt: 1500}}, {Population: {$lt: 500}} ] }, {Official_Name: 1} )
db.city.find({ $or: [{ Population: { $gt: 1500 } }, { Population: { $lt: 500 } }] }, { Official_Name: 1 })
db.city.find( { $or: [ {Population: {$gt: 1500}}, {Population: {$lt: 500}} ] }, {Official_Name: 1} )
42
55
farm
easy
SELECT Census_Ranking FROM city WHERE Status != 'Village'
Show the census ranking of cities whose status are not 'Village'.
db.city.find({Status: {$ne: 'Village'}}, {Census_Ranking: 1})
db.city.find({ Status: { $ne: 'Village' } }, { Census_Ranking: 1 })
db.city.find({Status: {$ne: 'Village'}}, {Census_Ranking: 1})
43
56
farm
easy
SELECT Census_Ranking FROM city WHERE Status != 'Village'
What are the census rankings of cities that do not have the status 'Village'?
db.city.find({Status: {$ne: 'Village'}}, {Census_Ranking: 1})
db.city.find({ Status: { $ne: 'Village' } }, { Census_Ranking: 1 })
db.city.find({Status: {$ne: 'Village'}}, {Census_Ranking: 1})
44
63
student_assessment
hard
SELECT student_id FROM students WHERE student_id NOT IN (SELECT student_id FROM student_course_attendance)
List the id of students who never attends courses?
db.Students.find({ "student_id": { "$nin": db.Student_Course_Attendance.distinct("student_id") } }, { "student_id": 1, "_id": 0 })
db.Students.find({ "student_id": { "$nin": db.Student_Course_Attendance.distinct("student_id") } }, { "student_id": 1, "_id": 0 })
.
45
64
student_assessment
hard
SELECT student_id FROM students WHERE student_id NOT IN (SELECT student_id FROM student_course_attendance)
What are the ids of every student who has never attended a course?
db.Students.find( { "student_id": { "$nin": db.Student_Course_Attendance.distinct("student_id") } }, { "_id": 0, "student_id": 1 } )
db.Students.find( { "student_id": { "$nin": db.Student_Course_Attendance.distinct("student_id") } }, { "_id": 0, "student_id": 1 } )
.
46
72
student_assessment
medium
SELECT count(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T2.student_id = 171
How many courses do the student whose id is 171 attend?
db.Student_Course_Attendance.aggregate([ { $match: { student_id: 171 } }, { $group: { _id: "$course_id" } }, { $count: "total_courses" } ])
db.Student_Course_Attendance.aggregate([ { $match: { student_id: 171 } }, { $group: { _id: "$course_id" } }, { $count: "total_courses" } ])
.
47
73
student_assessment
medium
SELECT count(*) FROM courses AS T1 JOIN student_course_attendance AS T2 ON T1.course_id = T2.course_id WHERE T2.student_id = 171
How many courses does the student with id 171 actually attend?
db.Student_Course_Attendance.aggregate([ { $match: { student_id: 171 } }, { $group: { _id: "$course_id" } }, { $count: "number_of_courses_attended" } ])
db.Student_Course_Attendance.aggregate([ { $match: { student_id: 171 } }, { $group: { _id: "$course_id" } }, { $count: "number_of_courses_attended" } ])
.
48
74
student_assessment
medium
SELECT T2.candidate_id FROM people AS T1 JOIN candidates AS T2 ON T1.person_id = T2.candidate_id WHERE T1.email_address = 'stanley.monahan@example.org'
Find id of the candidate whose email is stanley.monahan@example.org?
db.People.aggregate([ { $match: { email_address: "stanley.monahan@example.org" } }, { $lookup: { from: "Candidates", localField: "person_id", foreignField: "candidate_id", as: "candidate_info" } }, { $unwind: "$candidate_info" }, { $project: { candidate_id: "$candidate_info.candidate_id" } } ])
.
db.People.aggregate([ { $match: { email_address: "stanley.monahan@example.org" } }, { $lookup: { from: "Candidates", localField: "person_id", foreignField: "candidate_id", as: "candidate_info" } }, { $unwind: "$candidate_info" }, { $project: { candidate_id: "$candidate_info.candidate_id" } } ])
49
75
student_assessment
medium
SELECT T2.candidate_id FROM people AS T1 JOIN candidates AS T2 ON T1.person_id = T2.candidate_id WHERE T1.email_address = 'stanley.monahan@example.org'
What is the id of the candidate whose email is stanley.monahan@example.org?
db.People.aggregate([ { $match: { email_address: 'stanley.monahan@example.org' } }, { $lookup: { from: 'Candidates', localField: 'person_id', foreignField: 'candidate_id', as: 'candidate_info' } }, { $unwind: '$candidate_info' }, { $project: { candidate_id: '$candidate_info.candidate_id' } } ])
db.People.aggregate([ { $match: { email_address: "stanley.monahan@example.org" } }, { $lookup: { from: "Candidates", localField: "person_id", foreignField: "candidate_id", as: "candidate_info" } }, { $unwind: "$candidate_info" }, { $project: { candidate_id: "$candidate_info.candidate_id" } } ])
db.People.aggregate([ { $match: { email_address: 'stanley.monahan@example.org' } }, { $lookup: { from: 'Candidates', localField: 'person_id', foreignField: 'candidate_id', as: 'candidate_info' } }, { $unwind: '$candidate_info' }, { $project: { candidate_id: '$candidate_info.candidate_id' } } ])
50
76
student_assessment
medium
SELECT candidate_id FROM candidate_assessments ORDER BY assessment_date DESC LIMIT 1
Find id of the candidate who most recently accessed the course?
db.Candidate_Assessments.find({}, { candidate_id: 1 }).sort({ assessment_date: -1 }).limit(1)
db.Candidate_Assessments.find({}, { candidate_id: 1 }).sort({ assessment_date: -1 }).limit(1)
.
51
77
student_assessment
medium
SELECT candidate_id FROM candidate_assessments ORDER BY assessment_date DESC LIMIT 1
What is the id of the candidate who most recently accessed the course?
db.Candidate_Assessments.find({}, { candidate_id: 1 }).sort({ assessment_date: -1 }).limit(1)
db.Candidate_Assessments.find({}, { candidate_id: 1 }).sort({ assessment_date: -1 }).limit(1)
.
52
79
student_assessment
extra
SELECT T1.student_details FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1
What are the details of the student who registered for the most number of courses?
db.Students.aggregate([ { $lookup: { from: "Student_Course_Registrations", localField: "student_id", foreignField: "student_id", as: "registrations" } }, { $project: { "student_details": 1, "numberOfCourses": { $size: "$registrations" } } }, { $sort: { "numberOfCourses": -1 } }, { $limit: 1 }, { $project: { student_det...
db.Students.aggregate([ { $lookup: { from: "Student_Course_Registrations", localField: "student_id", foreignField: "student_id", as: "registrations" } }, { $project: { "student_details": 1, "numberOfCourses": { $size: "$registrations" } } }, { $sort: { "numberOfCourses": -1 } }, { $limit: 1 }, { $project: { student_det...
.
53
84
student_assessment
easy
SELECT candidate_id FROM candidate_assessments WHERE asessment_outcome_code = 'Pass'
Find id of candidates whose assessment code is 'Pass'?
db.Candidate_Assessments.find({asessment_outcome_code: 'Pass'}, {candidate_id: 1})
db.Candidate_Assessments.find({ asessment_outcome_code: 'Pass' }, { candidate_id: 1 })
db.Candidate_Assessments.find({asessment_outcome_code: 'Pass'}, {candidate_id: 1})
54
85
student_assessment
easy
SELECT candidate_id FROM candidate_assessments WHERE asessment_outcome_code = 'Pass'
What are the ids of the candidates that have an outcome code of Pass?
db.Candidate_Assessments.find({asessment_outcome_code: 'Pass'}, {candidate_id: 1})
db.Candidate_Assessments.find({asessment_outcome_code: 'Pass'}, { candidate_id: 1})
db.Candidate_Assessments.find({asessment_outcome_code: 'Pass'}, {candidate_id: 1})
55
86
student_assessment
hard
SELECT T3.cell_mobile_number FROM candidates AS T1 JOIN candidate_assessments AS T2 ON T1.candidate_id = T2.candidate_id JOIN people AS T3 ON T1.candidate_id = T3.person_id WHERE T2.asessment_outcome_code = 'Fail'
Find the cell mobile number of the candidates whose assessment code is 'Fail'?
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "candidate_assessments" } }, { $unwind: "$candidate_assessments" }, { $match: { "candidate_assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candid...
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "assessments" } }, { $unwind: "$assessments" }, { $match: { "assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candidate_id", foreignField: "person...
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "candidate_assessments" } }, { $unwind: "$candidate_assessments" }, { $match: { "candidate_assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candid...
56
87
student_assessment
hard
SELECT T3.cell_mobile_number FROM candidates AS T1 JOIN candidate_assessments AS T2 ON T1.candidate_id = T2.candidate_id JOIN people AS T3 ON T1.candidate_id = T3.person_id WHERE T2.asessment_outcome_code = 'Fail'
What are the cell phone numbers of the candidates that received an assessment code of 'Fail'?
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "candidate_assessments" } }, { $unwind: "$candidate_assessments" }, { $match: { "candidate_assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candid...
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "assessments" } }, { $unwind: "$assessments" }, { $match: { "assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candidate_id", foreignField: "person...
db.Candidates.aggregate([ { $lookup: { from: "Candidate_Assessments", localField: "candidate_id", foreignField: "candidate_id", as: "candidate_assessments" } }, { $unwind: "$candidate_assessments" }, { $match: { "candidate_assessments.asessment_outcome_code": "Fail" } }, { $lookup: { from: "People", localField: "candid...
57
88
student_assessment
easy
SELECT student_id FROM student_course_attendance WHERE course_id = 301
What are the id of students who registered course 301?
db.Student_Course_Registrations.find({course_id: 301}, {student_id: 1})
.
db.Student_Course_Registrations.find({course_id: 301}, {student_id: 1})
58
89
student_assessment
easy
SELECT student_id FROM student_course_attendance WHERE course_id = 301
What are the ids of the students who registered for course 301?
db.Student_Course_Registrations.find({course_id: 301}, {student_id: 1})
db.Student_Course_Registrations.find({course_id: 301}, { student_id: 1})
db.Student_Course_Registrations.find({course_id: 301}, {student_id: 1})
59
92
student_assessment
easy
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id
Find distinct cities of addresses of people?
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "pa" } }, { $unwind: "$pa" }, { $group: { _id: "$city" } }, { $project: { city: "$_id" } } ])
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "people_addresses" } }, { $match: { "people_addresses.address_id": { $exists: true } } }, { $group: { _id: "$city" } }, { $project: { city: "$_id" } } ])
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "pa" } }, { $unwind: "$pa" }, { $group: { _id: "$city" } }, { $project: { city: "$_id" } } ])
60
94
student_assessment
medium
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id
Find distinct cities of address of students?
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "address_join" } }, { $unwind: "$address_join" }, { $lookup: { from: "Students", localField: "address_join.person_id", foreignField: "student_id", as: "student_join" } }, { $unwind: "$student_join" ...
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "PA" } }, { $unwind: "$PA" }, { $lookup: { from: "Students", localField: "PA.person_id", foreignField: "student_id", as: "S" } }, { $unwind: "$S" }, { $group: { _id: "$city" } }, { $project: { city:...
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "address_join" } }, { $unwind: "$address_join" }, { $lookup: { from: "Students", localField: "address_join.person_id", foreignField: "student_id", as: "student_join" } }, { $unwind: "$student_join" ...
61
95
student_assessment
medium
SELECT DISTINCT T1.city FROM addresses AS T1 JOIN people_addresses AS T2 ON T1.address_id = T2.address_id JOIN students AS T3 ON T2.person_id = T3.student_id
What are the different cities where students live?
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "address_join" } }, { $unwind: "$address_join" }, { $lookup: { from: "Students", localField: "address_join.person_id", foreignField: "student_id", as: "student_join" } }, { $unwind: "$student_join" ...
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "pa" } }, { $unwind: "$pa" }, { $lookup: { from: "Students", localField: "pa.person_id", foreignField: "student_id", as: "s" } }, { $unwind: "$s" }, { $group: { _id: "$city" } }, { $project: { city:...
db.Addresses.aggregate([ { $lookup: { from: "People_Addresses", localField: "address_id", foreignField: "address_id", as: "address_join" } }, { $unwind: "$address_join" }, { $lookup: { from: "Students", localField: "address_join.person_id", foreignField: "student_id", as: "student_join" } }, { $unwind: "$student_join" ...
62
96
student_assessment
easy
SELECT course_name FROM courses ORDER BY course_name
List the names of courses in alphabetical order?
db.Courses.find({}, { course_name: 1 }).sort({ course_name: 1 })
db.Courses.find({}, { course_name: 1 }).sort({ course_name: 1 })
.
63
97
student_assessment
easy
SELECT course_name FROM courses ORDER BY course_name
What are the names of the courses in alphabetical order?
db.Courses.find({}, { course_name: 1 }).sort({ course_name: 1 })
db.Courses.find({}, { course_name: 1 }).sort({ course_name: 1 })
.
64
98
student_assessment
easy
SELECT first_name FROM people ORDER BY first_name
List the first names of people in alphabetical order?
db.People.find({}, {first_name: 1}).sort({first_name: 1})
db.People.find({}, { first_name: 1 }).sort({ first_name: 1 })
db.People.find({}, {first_name: 1}).sort({first_name: 1})
65
99
student_assessment
easy
SELECT first_name FROM people ORDER BY first_name
What are the first names of the people in alphabetical order?
db.People.find({}, {first_name: 1}).sort({first_name: 1})
db.People.find({}, { first_name: 1 }).sort({ first_name: 1 })
db.People.find({}, {first_name: 1}).sort({first_name: 1})
66
101
student_assessment
hard
SELECT student_id FROM student_course_registrations UNION SELECT student_id FROM student_course_attendance
What are the ids of the students who either registered or attended a course?
db.Student_Course_Registrations.aggregate([ { $lookup: { from: "Student_Course_Attendance", localField: "student_id", foreignField: "student_id", as: "attendance" } }, { $project: { student_id: 1 } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $project: { student_id: 1 } } ] } }, { $group: { _id: ...
db.Student_Course_Registrations.aggregate([ { $lookup: { from: "Student_Course_Attendance", localField: "student_id", foreignField: "student_id", as: "attendance" } }, { $project: { student_id: 1 } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $project: { student_id: 1 } } ] } }, { $group: { _id: ...
.
67
102
student_assessment
hard
SELECT course_id FROM student_course_registrations WHERE student_id = 121 UNION SELECT course_id FROM student_course_attendance WHERE student_id = 121
Find the id of courses which are registered or attended by student whose id is 121?
db.Student_Course_Registrations.aggregate([ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } } ] } }, { $group: { _id: "$_id" } }, { $project: { course_id: "$_id" } } ])
db.Student_Course_Registrations.aggregate([ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } } ] } }, { $group: { _id: "$_id" } }, { $project: { course_id: "$_id" } } ])
.
68
103
student_assessment
hard
SELECT course_id FROM student_course_registrations WHERE student_id = 121 UNION SELECT course_id FROM student_course_attendance WHERE student_id = 121
What are the ids of the courses that are registered or attended by the student whose id is 121?
db.Student_Course_Registrations.aggregate([ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } } ] } }, { $group: { _id: "$_id" } }, { $project: { course_id: "$_id" } } ])
db.Student_Course_Registrations.aggregate([ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } }, { $unionWith: { coll: "Student_Course_Attendance", pipeline: [ { $match: { student_id: 121 } }, { $group: { _id: "$course_id" } } ] } }, { $group: { _id: "$_id" } }, { $project: { course_id: "$_id" } } ])
.
69
114
bike_1
medium
SELECT city , max(lat) FROM station GROUP BY city
For each city, return the highest latitude among its stations.
db.station.aggregate([ { $group: { _id: "$city", maxLat: { $max: "$lat" } } } ])
db.station.aggregate([ { $group: { _id: "$city", maxLatitude: { $max: "$lat" } } }, { $project: { city: "$_id", maxLatitude: 1 } } ])
db.station.aggregate([ { $group: { _id: "$city", maxLat: { $max: "$lat" } } } ])
70
115
bike_1
medium
SELECT city , max(lat) FROM station GROUP BY city
For each city, what is the highest latitude for its stations?
db.station.aggregate([ { $group: { _id: "$city", maxLat: { $max: "$lat" } } } ])
db.station.aggregate([ { $group: { _id: "$city", highestLatitude: { $max: "$lat" } } }, { $project: { city: "$_id", highestLatitude: 1 } } ])
db.station.aggregate([ { $group: { _id: "$city", maxLat: { $max: "$lat" } } } ])
71
116
bike_1
medium
SELECT start_station_name , end_station_name FROM trip ORDER BY id LIMIT 3
Give me the start station and end station for the trips with the three oldest id.
db.trip.find({}, { start_station_name: 1, end_station_name: 1}).sort({id: 1}).limit(3)
db.trip.find({}, { start_station_name: 1, end_station_name: 1 }).sort({ id: 1 }).limit(3)
db.trip.find({}, { start_station_name: 1, end_station_name: 1}).sort({id: 1}).limit(3)
72
117
bike_1
medium
SELECT start_station_name , end_station_name FROM trip ORDER BY id LIMIT 3
What is the station station and end station for the trips with the three smallest ids?
db.trip.find({}, { start_station_name: 1, end_station_name: 1}).sort({id: 1}).limit(3)
db.trip.find({}, { start_station_name: 1, end_station_name: 1 }).sort({ id: 1 }).limit(3)
db.trip.find({}, { start_station_name: 1, end_station_name: 1}).sort({id: 1}).limit(3)
73
118
bike_1
medium
SELECT avg(lat) , avg(long) FROM station WHERE city = 'San Jose'
What is the average latitude and longitude of stations located in San Jose city?
db.station.aggregate([ { $match: { city: "San Jose" } }, { $group: { _id: null, avgLat: { $avg: "$lat" }, avgLong: { $avg: "$long" } } }, { $project: { avgLat: 1, avgLong: 1 } } ])
db.station.aggregate([ { $match: { city: "San Jose" } }, { $group: { _id: null, avgLat: { $avg: "$lat" }, avgLong: { $avg: "$long" } } }, { $project: { avgLat: 1, avgLong: 1 } } ])
db.station.aggregate([ { $match: { city: "San Jose" } }, { $group: { _id: null, avgLat: { $avg: "$lat" }, avgLong: { $avg: "$long" } } }, { $project: { avgLat: 1, avgLong: 1 } } ])
74
119
bike_1
medium
SELECT avg(lat) , avg(long) FROM station WHERE city = 'San Jose'
What is the average latitude and longitude in San Jose?
db.station.aggregate([ { $match: { city: "San Jose" } }, { $group: { _id: null, avgLat: { $avg: "$lat" }, avgLong: { $avg: "$long" } } }, { $project: { avgLat: 1, avgLong: 1 } } ])
db.station.aggregate([ { $match: { city: 'San Jose' } }, { $group: { _id: null, average_latitude: { $avg: "$lat" }, average_longitude: { $avg: "$long" } } }, { $project: { average_latitude: 1, average_longitude: 1 } } ])
db.station.aggregate([ { $match: { city: "San Jose" } }, { $group: { _id: null, avgLat: { $avg: "$lat" }, avgLong: { $avg: "$long" } } }, { $project: { avgLat: 1, avgLong: 1 } } ])
75
121
bike_1
medium
SELECT id FROM trip ORDER BY duration LIMIT 1
What is the id of the shortest trip?
db.trip.find({}, {id: 1}).sort({duration: 1}).limit(1)
db.trip.find({}, {id: 1}).sort({duration: 1}).limit(1)
.
76
122
bike_1
medium
SELECT sum(duration) , max(duration) FROM trip WHERE bike_id = 636
What is the total and maximum duration of trips with bike id 636?
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, totalDuration: { $sum: "$duration" }, maxDuration: { $max: "$duration" } }}, { $project: { totalDuration: 1, maxDuration: 1 } } ])
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, total_duration: { $sum: "$duration" }, max_duration: { $max: "$duration" } }}, { $project: { total_duration: 1, max_duration: 1 } } ])
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, totalDuration: { $sum: "$duration" }, maxDuration: { $max: "$duration" } }}, { $project: { totalDuration: 1, maxDuration: 1 } } ])
77
123
bike_1
medium
SELECT sum(duration) , max(duration) FROM trip WHERE bike_id = 636
What is the total and maximum duration for all trips with the bike id 636?
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, totalDuration: { $sum: "$duration" }, maxDuration: { $max: "$duration" } }}, { $project: { totalDuration: 1, maxDuration: 1 } } ])
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, total_duration: { $sum: "$duration" }, max_duration: { $max: "$duration" } } }, { $project: { total_duration: 1, max_duration: 1 } } ])
db.trip.aggregate([ { $match: { bike_id: 636 } }, { $group: { _id: null, totalDuration: { $sum: "$duration" }, maxDuration: { $max: "$duration" } }}, { $project: { totalDuration: 1, maxDuration: 1 } } ])
78
128
bike_1
easy
SELECT count(DISTINCT city) FROM station
What is the number of distinct cities the stations are located at?
db.station.aggregate([ { $group: { _id: "$city" } }, { $count: "distinct_cities" } ])
db.station.aggregate([ { $group: { _id: "$city" } }, { $count: "distinct_cities" } ])
.
79
132
bike_1
medium
SELECT DISTINCT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available = 7
Return the unique name for stations that have ever had 7 bikes available.
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $match: { "status_info.bikes_available": 7 } }, { $project: { name: 1 } } ])
db.status.aggregate([ { $match: { bikes_available: 7 } }, { $group: { _id: "$station_id" } }, { $lookup: { from: "station", localField: "_id", foreignField: "id", as: "station_info" }}, { $unwind: "$station_info" }, { $project: { "station_info.name": 1 } }, { $group: { _id: "$station_info.name" } } ])
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $match: { "status_info.bikes_available": 7 } }, { $project: { name: 1 } } ])
80
133
bike_1
medium
SELECT DISTINCT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id WHERE T2.bikes_available = 7
What are the different names for each station that has ever had 7 bikes available?
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $match: { "status_info.bikes_available": 7 } }, { $group: { _id: "$name" } }, { $project: { name: "$_id" } } ])
.
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $match: { "status_info.bikes_available": 7 } }, { $group: { _id: "$name" } }, { $project: { name: "$_id" } } ])
81
134
bike_1
extra
SELECT start_station_name , start_station_id FROM trip WHERE start_date LIKE '8/%' GROUP BY start_station_name ORDER BY COUNT(*) DESC LIMIT 1
Which start station had the most trips starting from August? Give me the name and id of the station.
db.trip.aggregate([ { $match: { start_date: { $regex: /^8\// } } }, { $group: { _id: { start_station_name: "$start_station_name", start_station_id: "$start_station_id" }, count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { start_station_name: "$_id.start_station_name", start_station_id: "$_id...
db.trip.aggregate([ {$match: {start_date: /^8\//}}, {$group: {_id: {start_station_name: "$start_station_name", start_station_id: "$start_station_id"}, count: {$sum: 1}}}, {$sort: {count: -1}}, {$limit: 1}, {$project: {start_station_name: "$_id.start_station_name", start_station_id: "$_id.start_station_id"}} ])
db.trip.aggregate([ { $match: { start_date: { $regex: /^8\// } } }, { $group: { _id: { start_station_name: "$start_station_name", start_station_id: "$start_station_id" }, count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { start_station_name: "$_id.start_station_name", start_station_id: "$_id...
82
135
bike_1
extra
SELECT start_station_name , start_station_id FROM trip WHERE start_date LIKE '8/%' GROUP BY start_station_name ORDER BY COUNT(*) DESC LIMIT 1
What are the start station's name and id for the one that had the most start trips in August?
db.trip.aggregate([ { $match: { start_date: { $regex: /^8\// } } }, { $group: { _id: { start_station_name: "$start_station_name", start_station_id: "$start_station_id" }, count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { start_station_name: "$_id.start_station_name", start_station_id: "$_id...
db.trip.aggregate([ { $match: { start_date: { $regex: '^8/' } } }, { $group: { _id: { start_station_name: "$start_station_name", start_station_id: "$start_station_id" }, count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { start_station_name: "$_id.start_station_name", start_station_id: "$_id....
db.trip.aggregate([ { $match: { start_date: { $regex: /^8\// } } }, { $group: { _id: { start_station_name: "$start_station_name", start_station_id: "$start_station_id" }, count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 1 }, { $project: { start_station_name: "$_id.start_station_name", start_station_id: "$_id...
83
140
bike_1
hard
SELECT T1.lat , T1.long , T1.city FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id ORDER BY T2.duration LIMIT 1
What is the latitude, longitude, city of the station from which the shortest trip started?
db.station.aggregate([ { $lookup: { from: "trip", localField: "id", foreignField: "start_station_id", as: "trips" } }, { $unwind: "$trips" }, { $sort: { "trips.duration": 1 } }, { $limit: 1 }, { $project: { lat: 1, long: 1, city: 1 } } ])
db.trip.aggregate([ { $sort: { duration: 1 } }, { $limit: 1 }, { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station_info" } }, { $unwind: "$station_info" }, { $project: { lat: "$station_info.lat", long: "$station_info.long", city: "$station_info.city" } } ])
db.station.aggregate([ { $lookup: { from: "trip", localField: "id", foreignField: "start_station_id", as: "trips" } }, { $unwind: "$trips" }, { $sort: { "trips.duration": 1 } }, { $limit: 1 }, { $project: { lat: 1, long: 1, city: 1 } } ])
84
141
bike_1
hard
SELECT T1.lat , T1.long , T1.city FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id ORDER BY T2.duration LIMIT 1
What is the latitude, longitude, and city of the station from which the trip with smallest duration started?
db.station.aggregate([ { $lookup: { from: "trip", localField: "id", foreignField: "start_station_id", as: "trips" } }, { $unwind: "$trips" }, { $sort: { "trips.duration": 1 } }, { $limit: 1 }, { $project: { lat: 1, long: 1, city: 1 } } ])
db.trip.aggregate([ { $sort: { duration: 1 } }, { $limit: 1 }, { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station_info" } }, { $unwind: "$station_info" }, { $project: { lat: "$station_info.lat", long: "$station_info.long", city: "$station_info.city" } } ])
db.station.aggregate([ { $lookup: { from: "trip", localField: "id", foreignField: "start_station_id", as: "trips" } }, { $unwind: "$trips" }, { $sort: { "trips.duration": 1 } }, { $limit: 1 }, { $project: { lat: 1, long: 1, city: 1 } } ])
85
142
bike_1
hard
SELECT id FROM station WHERE city = 'San Francisco' INTERSECT SELECT station_id FROM status GROUP BY station_id HAVING avg(bikes_available) > 10
What are the ids of stations that are located in San Francisco and have average bike availability above 10.
db.station.aggregate([ { $match: { city: "San Francisco" } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_data" } }, { $unwind: "$status_data" }, { $group: { _id: "$id", avgBikesAvailable: { $avg: "$status_data.bikes_available" } } }, { $match: { avgBikesAvailable: { $gt: 10 }...
db.station.aggregate([ { $match: { city: "San Francisco" } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $group: { _id: "$id", averageBikes: { $avg: "$status_info.bikes_available" } } }, { $match: { averageBikes: { $gt: 10 } } }, { $p...
db.station.aggregate([ { $match: { city: "San Francisco" } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_data" } }, { $unwind: "$status_data" }, { $group: { _id: "$id", avgBikesAvailable: { $avg: "$status_data.bikes_available" } } }, { $match: { avgBikesAvailable: { $gt: 10 }...
86
143
bike_1
hard
SELECT id FROM station WHERE city = 'San Francisco' INTERSECT SELECT station_id FROM status GROUP BY station_id HAVING avg(bikes_available) > 10
What are the ids of the stations in San Francisco that normally have more than 10 bikes available?
db.station.aggregate([ { $match: { city: "San Francisco" } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $group: { _id: "$status_info.station_id", averageBikes: { $avg: "$status_info.bikes_available" } } }, { $match: { averageBikes: {...
db.station.aggregate([ { $match: { city: "San Francisco" } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $group: { _id: "$status_info.station_id", averageBikes: { $avg: "$status_info.bikes_available" } } }, { $match: { averageBikes: {...
.
87
144
bike_1
extra
SELECT T1.name , T1.id FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING avg(T2.bikes_available) > 14 UNION SELECT name , id FROM station WHERE installation_date LIKE '12/%'
What are the names and ids of stations that had more than 14 bikes available on average or were installed in December?
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $group: { _id: "$id", name: { $first: "$name" }, averageBikesAvailable: { $avg: "$status_info.bikes_available" } } }, { $match: { $or: [ { averageBikesAvailable: { $gt:...
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $unwind: "$status_info" }, { $group: { _id: "$id", name: { $first: "$name" }, averageBikesAvailable: { $avg: "$status_info.bikes_available" } } }, { $match: { $or: [ { averageBikesAvailable: { $gt:...
.
88
145
bike_1
extra
SELECT T1.name , T1.id FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING avg(T2.bikes_available) > 14 UNION SELECT name , id FROM station WHERE installation_date LIKE '12/%'
What are the names and ids of all stations that have more than 14 bikes available on average or had bikes installed in December?
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $addFields: { average_bikes_available: { $avg: "$status_info.bikes_available" } } }, { $match: { $or: [ { average_bikes_available: { $gt: 14 } }, { installation_date: { $regex: '^12/' } } ] } }, { ...
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $addFields: { average_bikes_available: { $avg: "$status_info.bikes_available" } } }, { $match: { $or: [ { average_bikes_available: { $gt: 14 } }, { installation_date: { $regex: '^12/' } } ] } }, { ...
.
89
146
bike_1
extra
SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT (*) DESC LIMIT 3
What is the 3 most common cloud cover rates in the region of zip code 94107?
db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: "$cloud_cover", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 3 } , { $project: { cloud_cover: "$_id" } }])
.
db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: "$cloud_cover", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 3 } , { $project: { cloud_cover: "$_id" } }])
90
147
bike_1
extra
SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT (*) DESC LIMIT 3
What are the 3 most common cloud covers in the zip code of 94107?
db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: "$cloud_cover", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 3 } , { $project: { cloud_cover: "$_id" } }])
.
db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: "$cloud_cover", count: { $sum: 1 } } }, { $sort: { count: -1 } }, { $limit: 3 } , { $project: { cloud_cover: "$_id" } }])
91
150
bike_1
extra
SELECT avg(bikes_available) FROM status WHERE station_id NOT IN (SELECT id FROM station WHERE city = 'Palo Alto')
What is the average bike availability in stations that are not located in Palo Alto?
db.station.aggregate([ { $match: { city: { $ne: "Palo Alto" } } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status" } }, { $unwind: "$status" }, { $group: { _id: null, avgBikesAvailable: { $avg: "$status.bikes_available" } } }, { $project: { avgBikesAvailable: 1 } } ])
db.status.aggregate([ { $lookup: { from: "station", localField: "station_id", foreignField: "id", as: "station_info" } }, { $match: { "station_info.city": { $ne: "Palo Alto" } } }, { $group: { _id: null, averageBikesAvailable: { $avg: "$bikes_available" } } }, { $project: { averageBikesAvailable: 1 } } ])
db.station.aggregate([ { $match: { city: { $ne: "Palo Alto" } } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status" } }, { $unwind: "$status" }, { $group: { _id: null, avgBikesAvailable: { $avg: "$status.bikes_available" } } }, { $project: { avgBikesAvailable: 1 } } ])
92
151
bike_1
extra
SELECT avg(bikes_available) FROM status WHERE station_id NOT IN (SELECT id FROM station WHERE city = 'Palo Alto')
What is the average bike availablility for stations not in Palo Alto?
db.station.aggregate([ { $match: { city: { $ne: "Palo Alto" } } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status" } }, { $unwind: "$status" }, { $group: { _id: null, avgBikesAvailable: { $avg: "$status.bikes_available" } } }, { $project: { avgBikesAvailable: 1 } } ])
db.status.aggregate([ { $lookup: { from: "station", localField: "station_id", foreignField: "id", as: "station_info" } }, { $match: { "station_info.city": { $ne: "Palo Alto" } } }, { $group: { _id: null, averageBikesAvailable: { $avg: "$bikes_available" } } }, { $project: { averageBikesAvailable: 1 } } ])
db.station.aggregate([ { $match: { city: { $ne: "Palo Alto" } } }, { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status" } }, { $unwind: "$status" }, { $group: { _id: null, avgBikesAvailable: { $avg: "$status.bikes_available" } } }, { $project: { avgBikesAvailable: 1 } } ])
93
160
bike_1
extra
SELECT date , zip_code FROM weather WHERE min_dew_point_f < (SELECT min(min_dew_point_f) FROM weather WHERE zip_code = 94107)
On which day and in which zip code was the min dew point lower than any day in zip code 94107?
db.weather.aggregate([ { $match: { min_dew_point_f: { $lt: db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: null, min_dew_point_f: { $min: "$min_dew_point_f" } } } ]).toArray()[0].min_dew_point_f } } }, { $project: { date: 1, zip_code: 1 } } ])
.
db.weather.aggregate([ { $match: { min_dew_point_f: { $lt: db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: null, min_dew_point_f: { $min: "$min_dew_point_f" } } } ]).toArray()[0].min_dew_point_f } } }, { $project: { date: 1, zip_code: 1 } } ])
94
161
bike_1
extra
SELECT date , zip_code FROM weather WHERE min_dew_point_f < (SELECT min(min_dew_point_f) FROM weather WHERE zip_code = 94107)
Which days had a minimum dew point smaller than any day in zip code 94107, and in which zip codes were those measurements taken?
db.weather.aggregate([ { $match: { min_dew_point_f: { $lt: db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: null, min_dew_point_f: { $min: "$min_dew_point_f" } } } ]).toArray()[0].min_dew_point_f } } }, { $project: { date: 1, zip_code: 1 } } ])
db.weather.aggregate([ { $group: { _id: "$zip_code", minDewPoint: { $min: "$min_dew_point_f" } } }, { $match: { _id: 94107 } }, { $project: { minDewPoint94107: "$minDewPoint" } }, { $lookup: { from: "weather", let: { minDewPointZip: "$minDewPoint94107" }, pipeline: [ { $match: { $expr: { $lt: ["$min_dew_point_f", "$$mi...
db.weather.aggregate([ { $match: { min_dew_point_f: { $lt: db.weather.aggregate([ { $match: { zip_code: 94107 } }, { $group: { _id: null, min_dew_point_f: { $min: "$min_dew_point_f" } } } ]).toArray()[0].min_dew_point_f } } }, { $project: { date: 1, zip_code: 1 } } ])
95
164
bike_1
hard
SELECT T1.id FROM trip AS T1 JOIN station AS T2 ON T1.start_station_id = T2.id ORDER BY T2.dock_count DESC LIMIT 1
Which trip started from the station with the largest dock count? Give me the trip id.
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "start_station" } }, { $unwind: "$start_station" }, { $sort: { "start_station.dock_count": -1 } }, { $limit: 1 }, { $project: { id: "$id" } } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station_info" } }, { $unwind: "$station_info" }, { $sort: { "station_info.dock_count": -1 } }, { $limit: 1 }, { $project: { id: 1 } } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "start_station" } }, { $unwind: "$start_station" }, { $sort: { "start_station.dock_count": -1 } }, { $limit: 1 }, { $project: { id: "$id" } } ])
96
165
bike_1
hard
SELECT T1.id FROM trip AS T1 JOIN station AS T2 ON T1.start_station_id = T2.id ORDER BY T2.dock_count DESC LIMIT 1
What is the id of the trip that started from the station with the highest dock count?
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station" } }, { $unwind: "$station" }, { $sort: { "station.dock_count": -1 } }, { $limit: 1 }, { $project: { "_id": 0, "id": 1 } } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station" } }, { $unwind: "$station" }, { $sort: { "station.dock_count": -1 } }, { $limit: 1 }, { $project: { id: 1 } } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "start_station_id", foreignField: "id", as: "station" } }, { $unwind: "$station" }, { $sort: { "station.dock_count": -1 } }, { $limit: 1 }, { $project: { "_id": 0, "id": 1 } } ])
97
166
bike_1
medium
SELECT count(*) FROM trip AS T1 JOIN station AS T2 ON T1.end_station_id = T2.id WHERE T2.city != 'San Francisco'
Count the number of trips that did not end in San Francisco city.
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "end_station" } }, { $match: { "end_station.city": { $ne: "San Francisco" } } }, { $count: "total" } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "station_info" } }, { $match: { "station_info.city": { $ne: "San Francisco" } } }, { $count: "non_sf_trip_count" } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "end_station" } }, { $match: { "end_station.city": { $ne: "San Francisco" } } }, { $count: "total" } ])
98
167
bike_1
medium
SELECT count(*) FROM trip AS T1 JOIN station AS T2 ON T1.end_station_id = T2.id WHERE T2.city != 'San Francisco'
How many trips did not end in San Francisco?
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "end_station" } }, { $match: { "end_station.city": { $ne: "San Francisco" } } }, { $count: "total" } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "end_station" } }, { $match: { "end_station.city": { $ne: "San Francisco" } } }, { $count: "trips_not_in_san_francisco" } ])
db.trip.aggregate([ { $lookup: { from: "station", localField: "end_station_id", foreignField: "id", as: "end_station" } }, { $match: { "end_station.city": { $ne: "San Francisco" } } }, { $count: "total" } ])
99
172
bike_1
extra
SELECT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING avg(bikes_available) > 10 EXCEPT SELECT name FROM station WHERE city = 'San Jose'
What are names of stations that have average bike availability above 10 and are not located in San Jose city?
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $match: { city: { $ne: "San Jose" } } }, { $unwind: "$status_info" }, { $group: { _id: "$_id", name: { $first: "$name" }, avgBikesAvailable: { $avg: "$status_info.bikes_available" } } }, { $match: ...
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "status_info" } }, { $match: { city: { $ne: "San Jose" } } }, { $unwind: "$status_info" }, { $group: { _id: "$_id", name: { $first: "$name" }, avgBikesAvailable: { $avg: "$status_info.bikes_available" } } }, { $match: ...
.
100
173
bike_1
extra
SELECT T1.name FROM station AS T1 JOIN status AS T2 ON T1.id = T2.station_id GROUP BY T2.station_id HAVING avg(bikes_available) > 10 EXCEPT SELECT name FROM station WHERE city = 'San Jose'
What are the names of all stations that have more than 10 bikes available and are not located in San Jose?
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "station_status" } }, { $match: { city: { $ne: "San Jose" } } }, { $unwind: "$station_status" }, { $group: { _id: "$station_status.station_id", averageBikesAvailable: { $avg: "$station_status.bikes_available" }, name: ...
db.station.aggregate([ { $lookup: { from: "status", localField: "id", foreignField: "station_id", as: "station_status" } }, { $match: { city: { $ne: "San Jose" } } }, { $unwind: "$station_status" }, { $group: { _id: "$station_status.station_id", averageBikesAvailable: { $avg: "$station_status.bikes_available" }, name: ...
.
End of preview. Expand in Data Studio

DocSpider: a Dataset of Cross-Domain Natural Language Querying for MongoDB

Arif Görkem Özer, Fırat Çekinel, Pınar Karagöz, İsmail Hakkı Toroslu

You can access the paper published in Natural Language Processing journal, from this link.

DocSpider dataset is generated by using the widely-known text-to-SQL dataset, Spider.

See GitHub repository for more details, including benchmark pipeline scripts for text to MongoDB query conversion.

Overview

This repository contains a dataset, called DocSpider, for the task of converting natural language (English) to MongoDB querying language (MQL).

Downloads last month
54