Last active
July 3, 2016 04:02
-
-
Save KalikaKay/cc407ec2025d234434266c218ce2f718 to your computer and use it in GitHub Desktop.
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
/* Match for numbers in zip */ | |
db.zips.aggregate([ | |
{$project: { first_char: {$substr : ["$city",0,1]}, population: "$pop" } }, | |
{$group:{ _id: "$first_char", summation: {$sum:"$population"}}}, | |
{$match: { _id: { $in: [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] } } } , | |
{$group:{ _id: null, total: {$sum:"$summation"}}} | |
]) | |
/* I don't want any quizzes */ | |
db.grades.aggregate ( | |
[ | |
{ $unwind:"$scores" }, | |
{ $match: {"scores.type": {$ne: "quiz"}}}, | |
{ $group: | |
{ | |
_id: | |
{ | |
class: "$class_id" | |
} , | |
AvgScore: | |
{ | |
$avg: "$scores.score" | |
} | |
} | |
}, | |
{ $sort: { "AvgScore": 1 } } | |
], | |
{ allowDiskUse: true } | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Memory all alone in the moonlight ...