Database
[{"id":"2020-08","totalWholesalePrice":NumberInt(89),"totalPurchasePrice":135.55,"count":8.0,"totalAmountDue":46.55,"transactions":{"_id":ObjectId("5f3faf2216d7a517bc51bfae"),"date":ISODate("2020-04-20T11:23:40Z"),"statementMonth":"2020-08","merchant":"M1268360","amountPaid":"40"}},{"id":"2020-08","totalWholesalePrice":NumberInt(89),"totalPurchasePrice":135.55,"count":8.0,"totalAmountDue":46.55,"transactions":{"_id":ObjectId("5f3fc13f16d7a517bc51c047"),"date":ISODate("2020-04-20T11:23:40Z"),"statementMonth":"2020-08","merchant":"M1268360","amountPaid":"2"}}]
Query
db.collection.aggregate([{$group:{"_id":"$id","transactions":{"$addToSet":"$transactions"},"totalWholesalePrice":{"$first":"$totalWholesalePrice"},"totalAmountPaid":{$sum:{$toInt:"$transactions.amountPaid"}}}}])