Database
db={order:[{id:1,price:249,store:1,status:true},{id:2,price:230,store:1,status:true},{id:3,price:240,store:1,status:true},{id:4,price:100,store:2,status:true},{id:5,price:150,store:2,status:true},{id:6,price:500,store:3,status:true},{id:7,price:70,store:4,status:true},],store:[{id:1,name:"Store A",status:true},{id:2,name:"Store B",status:true},{id:3,name:"Store C",status:true},{id:4,name:"Store D",status:false}]}
Query
db.store.aggregate([{"$lookup":{"from":"order",let:{id:"$id"},pipeline:[{$match:{$expr:{$eq:["$$id","$store"]}}},{$group:{_id:null,totalSale:{$sum:"$price"}}}],"as":"totalSale"}},{$unwind:"$totalSale"},{$addFields:{totalSale:"$totalSale.totalSale"}},{$sort:{totalSale:-1}}])