按某一字段fieldA分组,计算每组内,其他字段之和

agg = [
            {
                "$match": {
                    "create_time": {
                        "$gt": datetime.datetime(now.year, 1, 1).strftime("%Y-%m-%d %H:%M:%S"),
                        "$lte": now.strftime("%Y-%m-%d %H:%M:%S")
                    }
                }
            },
            {
                "$group": {
                    "_id": "$fieldA",
                    "a_count": {"$sum": "$statistics.call.a"},
                    "b_count": {"$sum": "$statistics.call.b"},
                    "ct_count": {"$sum": "$statistics.call.c"},
                }
            }
        ]

你可能感兴趣的:(按某一字段fieldA分组,计算每组内,其他字段之和)