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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -