MongoDB divide returns null when dividing by other variable
问题 I am trying to compute some numbers, but MongoDB returns null when using previous computed variable in $divide operator This is the query: db.apps.aggregate( {$project : { a: {$multiply : [2,2]}, b: {$divide: [5, "$a"]}, c: {$divide: [5, 4]} }}) Why "b" is null in the result: /* 0 */ { "result" : [ { "_id" : ObjectId("5361173d93861f6e5239714e"), "a" : 4, "b" : null, "c" : 1.25 }, { "_id" : ObjectId("536192c1938652d039fa0051"), "a" : 4, "b" : null, "c" : 1.25 } ], "ok" : 1 } EDIT: Thanks to