2015-09-02

MongoDB - Basic group by with a sum

db.COLLECTION_NAME.aggregate([
    {$group:
        {
            _id : "$FIELD_TO_GROUP_BY",
            RESULTING_SUM_FIELD_ALIAS : { $sum : "$FIELD_TO_SUM"}
        }
    }
]);

No comments:

Post a Comment