MongoDB Orders/sales aggregation group Per Month Sum Total + Count Field
问题 Who knows a better solution to group Orders by date and sum total and count by source. Of course I can group by Source and then I get only totals for this source only, I can alter the result thereafter to get the desired result. But I would like to know if it is possible in one simple $group statement. Eg. ordersByApp = 1, ordersByWEB = 2 Orders collection { _id: 'XCUZO0', date: "2020-02-01T00:00:03.243Z" total: 9.99, source: 'APP' }, { _id: 'XCUZO1', date: "2020-01-05T00:00:03.243Z" total: 9