mongo aggregate查询:
db.collection.aggregate({ $group:{ _id:"$id", //"$_id"代表引用集合中_id列 max_value:{$max:"$times"} //"$times"代表引用集合中times列 }, $match:{times:{$gte:100}} })
相当于sql查询:
select _id, max(times) from collection where times>=100
时间: 2024-11-08 21:36:00