In this type of queries the results of several partial queries are merged and grouped together to form a new result. The following query returns a list of all US states, that have more than 10 million inhabitants.
[ { $group : { _id : "$state", totalPop : { $sum : "$pop" } } }, { $match : { totalPop : { $gte : 10000000 } } } ]
The queries must be embedded in an array. Are the appropriate braces left out, it leads to an error message.
A detailed documentation of the Mongo aggregation framework can be found here: http://docs.mongodb.org/manual/core/aggregation-introduction/