1

I want to sum up a field over several documents like these:

{"_id":ObjectId("123"), "steps" : 50},
{"_id":ObjectId("456"), "steps" : 15},
{"_id":ObjectId("789"), "steps" : 80}

Goal: Give the sum of steps over all documents (should be 50+15+80=145 steps)
I want to use the RockMongo Query UI (the input field which accepts JSON Queries). There are answers in stackoverflow but I am not able to use them in the Query UI of rockmongo. See this: Taking sum of "column" in MongoDB

Update:

I tried this query but the response of Rockmongo is: "No records is found."

{ 
"aggregate" : "COLLECTION_NAME",                                          
  "pipeline" : 
    [{"$group": { 
        "_id": "null", 
        "total": { "$sum": "$steps" } 
        }
    }]                
}
Community
  • 1
  • 1
Sorcerer
  • 854
  • 1
  • 8
  • 20

0 Answers0