Database

db={"products":[{"_id":1,"ProductName":"product 1","Price":100,"SellerId":1},{"_id":2,"ProductName":"product 2","Price":200,"SellerId":2},{"_id":3,"ProductName":"product 3","Price":50,"SellerId":1}],"orders":[{"_id":1,"ProductId":1,"Price":100,"Quantity":2,"Total":200,"Status":true},{"_id":2,"ProductId":2,"Price":200,"Quantity":10,"Total":2000,"Status":true}]}

Query

db.products.aggregate([{$lookup:{from:"orders",localField:"_id",foreignField:"ProductId",as:"requests.service"}},{$unwind:"$requests.service"},{$group:{_id:"$_id",totalAmount:{$sum:"$requests.service.Total"}}},{$sort:{"totalAmount":1}}])

Result