Created
March 31, 2013 22:18
-
-
Save kinisoftware/5282233 to your computer and use it in GitHub Desktop.
Curso MongoDB Java - Week5 - HW5-3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.grades.aggregate([{$unwind:"$scores"}, {$match:{$or:[{"scores.type":"homework"}, {"scores.type":"exam"}]}}, {$group:{_id:{student_id:"$student_id", class_id:"$class_id"}, avg_score:{$avg:"$scores.score"}}}, {$group:{_id:"$_id.class_id", avg_score_class:{$avg:"$avg_score"}}}, {$sort:{avg_score_class:1}}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment