mongodb get maximum value from collection
db.collection.aggregate([{
$group : { _id: null, max: { $max : "$age" }}
}]);
mongodb get maximum value from collection
db.collection.aggregate([{
$group : { _id: null, max: { $max : "$age" }}
}]);
mongodb get max value
db.collection.find().sort({age:-1}).limit(1) // for MAX
db.collection.find().sort({age:+1}).limit(1) // for MIN
mongodb get maximum value from collection
db.collection.find().sort("age",-1).limit(1) // for MAX
db.collection.find().sort("age", 1).limit(1) // for MIN
db.collection.find().sort("age", pymongo.DESCENDING).limit(1) // for MAX
db.collection.find().sort("age", pymongo.ASCENDING).limit(1) // for MIN
mongodb get maximum value from collection
db.collection.aggregate([{
$group : { _id: null, max: { $max : "$age" }}
}]);
mongodb get max value
db.collection.find().sort({age:-1}).limit(1) // for MAX
db.collection.find().sort({age:+1}).limit(1) // for MIN
mongodb get maximum value from collection
db.collection.find().sort("age",-1).limit(1) // for MAX
db.collection.find().sort("age", 1).limit(1) // for MIN
db.collection.find().sort("age", pymongo.DESCENDING).limit(1) // for MAX
db.collection.find().sort("age", pymongo.ASCENDING).limit(1) // for MIN
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us