MongoDB Documentation, Release 3.0.4 { a: 2, b: 2 } { a: 2, b: 2 } db.records.distinct( "b" ) [ 0, 1, 4, 2 ] The results of this operation would resemble: Consider the following db.collection.distinct() operation which returns the distinct values of the field b : The group operation takes a number of documents that match a query, and then collects groups of documents based on the value of a field or fields. It returns an array of documents with computed results for each group of documents. Access the grouping functionality via the group command or the db.collection.group() method in the mongo shell. Warning: group does not support data in sharded collections. In addition, the results of the group operation must be no larger than 16 megabytes. Consider the following group operation: Given a collection named records with the following documents: Consider the following group operation which groups documents by the field a , where a is less than 3 , and sums the field count for each group: The results of this group operation would resemble the following: The $group for related functionality in the aggregation pipeline (page 440). Chapter 7. Aggregation 446 See also: Example Group db.records.group( { key: { a: 1 }, cond: { a: { $lt: 3 } }, reduce: function (cur, result) { result.count += cur.count }, initial: { count: 0 } } ) [ { a: 1, count: 15 }, { a: 2, count: 4 } ] { a: 1, count: 4 } { a: 1, count: 2 } { a: 1, count: 4 } { a: 2, count: 3 } { a: 2, count: 1 } { a: 1, count: 5 } { a: 4, count: 4 }