mongodb的aggregat根据条件统计总数
解决方法:
假如现在mongodb的一张表的名字为table_name,字段scid,sendtimesec,sendcount,successtype,统计scid为123456, sendtimesec在2018-10-15 07:59:00和2018-10-15 08:00:59之间的记录的sendcount的和,sendcount是别名,随便起名。
db.table_name.aggregate([{$match:{'scid':'123456','sendtimesec': { "$gte" : '2018-10-15 07:59:00', "$lte" : '2018-10-15 08:00:59' }}}, { $group:
{ _id: null, sendcount : {$sum : '$sendcount'}}}])
本文链接:http://www.yayihouse.com/yayishuwu/chapter/1634
向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti