OPTIONS

$last (aggregation)

$last

Returns the last value it encounters for its group.

Note

Only use $last when the $group follows an $sort operation. Otherwise, the result of this operation is unpredictable.

ON THIS PAGE