-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Query
I am the original reporter that led to https://jira.mongodb.org/browse/DOCS-8996
I believe that $sum should work this way as well.
For example:
db.some_collection.aggregate([{$group: { _id: null, average: {$avg: '$bad_field'}, sum: {$sum: '$bad_field'}, }}]);
will return null for average, and 0 for sum. It should return null for sum.
I'm a little surprised $sum was not updated when $avg was, and feel that this was an oversight.
Thanks
Ben
- is related to
-
SERVER-89419 Aggregation is inconsistent in applying $sum vs. $min/$max/$avg for non-existing fields
- Closed
- related to
-
SERVER-14691 $avg aggregation operator should return null instead of 0
- Closed