Answers for "find max value in column mongodb"

1

mongodb get max value

db.collection.find().sort({age:-1}).limit(1) // for MAX
db.collection.find().sort({age:+1}).limit(1) // for MIN
Posted by: Guest on February-10-2021
0

find only one max record in mongodb

db.temp.aggregate([
  {$group: {
      _id: "$total_wins",
      my_winner: {$push: "$$ROOT"}
  }},
  {$sort:{_id:-1}},
  {$limit:1}  ]).pretty()
Posted by: Guest on July-24-2021

Code answers related to "find max value in column mongodb"

Browse Popular Code Answers by Language