1、group by多个key

db.testcol.aggregate(
    {"$group": {_id:{card:"$card",account:"$account"}, "count": { "$sum": 1 } } }
)

2、group by having实现

mongodb 实现group by 多个key having count(*) >1

db.testcol.aggregate(
    {"$group": {_id:{card:"$card",account:"$account"}, "count": { "$sum": 1 } } },
    {"$match": {"_id" :{ "$ne" : null } , "count" : {"$gt": 1} } }
)

相关文章:

  • 2022-03-08
  • 2021-09-13
  • 2021-09-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-01-14
猜你喜欢
  • 2021-06-12
  • 2022-12-23
  • 2021-12-26
  • 2021-12-28
  • 2021-06-01
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案