Skip to content

Instantly share code, notes, and snippets.

@feifangit
Created October 8, 2013 07:40
Show Gist options
  • Save feifangit/6881044 to your computer and use it in GitHub Desktop.
Save feifangit/6881044 to your computer and use it in GitHub Desktop.
MongoDB university M101P HW5.3
db.stud.aggregate([
{$match:{"scores.type":{$in:["exam","homework"]}}},
{$unwind:"$scores"},
{$group:{_id:"$class_id",csall:{$avg:"$scores.score"}}},
{$sort:{csall:-1}},
{$limit:5}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment