- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Group Accumulator Operators >
- $min (aggregation)
$min (aggregation)¶
On this page
Definition¶
-
$min
¶ Returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.
$min
is an accumulator operator available only in the$group
stage.$min
has the following syntax:For more information on expressions, see Expressions.
Behavior¶
Changed in version 2.4.
If some, but not all, documents for the $min
operation have either a null
value for the field or are
missing the field, the $min
operator only considers the
non-null and the non-missing values for the field.
If all documents for the $min
operation have null
value for the field or are missing the field, the $min
operator returns null
for the minimum value.
Before 2.4, if any of the documents for the $min
operation
were missing the field, the $min
operator would not return any
value. If any of the documents for the $min
had the value
null
, the $min
operator would return a null
.