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.order.aggregate([{"$match":{status:true}},{"$group":{"_id":"$store","totalSale":{"$sum":"$price"}}},{$sort:{totoalSale:-1}}])