aggregation framework - How do i express this sql statement in mongodb -
aggregation framework - How do i express this sql statement in mongodb -
i tried poking around see basic examples.
i looking express following:
select average((a+b)/c) table
i have:
db.props.aggregate( [ { $group: { _id: "$id", a_: { $avg: "$a" },b_:{$avg:"$b"} } }, {$match:{a_:{$gt:0},b_:{$gt:0}}} ] ) but missing pieces. tried applying operations in $avg statement doesnt work.
something this?
{ $group: { _id: "$_id", average: { $avg: { $divide: [ {$add: ["$a","$b"]}, "$c" ] } } } } mongodb aggregation-framework
Comments
Post a Comment