Mongodb assignment notes
- TCO

- Apr 3, 2022
- 1 min read
Updated: Apr 4, 2022
Old question was like:
Write a query to display student ID and class ID for students whose score are greater than 99.00. Sort the result based on student ID from high to low and class ID from low to high.
db.grades.find({scores: { $elemMatch: { score: {$gt: 99} } } }, {_id: 0, student_id: 1, class_id: 1, scores: 1}).sort({student_id: -1, class_id: 1})
db.students.aggregate({
$group: {
_id:
{"scores": "$scores", "type": "$type"}
}
})


Comments