These are the results of two queries that I conducted.
First Query
db.game.aggregate( [
{ $group : { _id : "$HomeTeam", shots: { $sum : "$HS" } } },
{ $sort : { shots : -1 } }
])
Results of First Query
{ "_id" : "Man City", "shots" : 386 }
{ "_id" : "Liverpool", "shots" : 335 }
...
Second Query
db.game.aggregate( [
{ $group : { _id : "$AwayTeam", shots: { $sum : "$AS" } } },
{ $sort : { shots : -1 } }
])
Results of Second Query
{ "_id" : "Man City", "shots" : 297 }
{ "_id" : "Chelsea", "shots" : 281 }
...
I am now looking to create a query that combines and adds up the shots from both queries for the same team. For example:
{ "_id" : "Man City", "Totalshots" : 683 }