aggregat的$group和$match查询老是没结果,Fetched 0 record(s) in 0ms
解决方法:
交换$match和$group的位置,把$match语句放前面,$group放后面,例如:
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'} , successtype0 : {$sum : '$successtype0'}} }])