0

这是“页面”集合中的一些文档,我想在其中获取字段“memberProfile_editAccountProfile”的总和?

{
   "_id" : NumberLong(2013083117),
   "count" : 3000,
   "requests" : {
       "consumermx" : {            
       "NFCU" : {
               "memberDashboard_editDashboard" : 24,
               "memberProfile_editAccountProfile" : 1,
               "memberProfile_editPreferencesAssociation" : 1,
               "memberProfile_editPromotionReminder" : 59,
               "memberProfile_savePromotionReminder" : 6,
                        }
                      }
                 }
}

{
   "_id" : NumberLong(2013083118),
   "count" : 3000,
   "requests" : {
       "consumermx" : {            
       "NFCU" : {
               "memberDashboard_editDashboard" : 12,
               "memberProfile_editAccountProfile" : 23,
               "memberProfile_editPreferencesAssociation" : 6,
               "memberProfile_editPromotionReminder" : 21,
               "memberProfile_savePromotionReminder" : 9,
                        }
                      }
                 }
}
4

1 回答 1

0

这个怎么样?

db.Page.aggregate ([{"$group": { "_id":null,
                                 "editAccountProfileSum": {"$sum":"$requests.consumermx.NFCU.memberProfile_editAccountProfile"}}
                     }])
于 2013-10-18T16:28:11.160 回答