94cool

Mongodb 分组查询例子

db.tblCard.aggregate([
    {
        $match: {
            "sNo": {
                "$exists": true
            },
            "pNo": {
                "$exists": true
            },
            "pEffDate": {
                "$gte": ISODate("2017-01-01T00:00:00.000+0800"),
                "$lte": ISODate("2017-05-01T08:00:00.000+0800")
            }
        }
    },
    {
        $group: {
            "_id": {
                "pNo": "$pNo",
                "bNo": "$bNo"
            },
            "count": {
                "$sum": 1
            }
        }
    },
    {
        $out: "tblResult"//将结果输出到数据集中
    }
]);

分类:

技术点:

相关文章:

  • 2022-01-05
  • 2021-05-08
  • 2021-11-05
  • 2021-11-09
  • 2022-01-19
  • 2022-12-23
  • 2021-12-23
猜你喜欢
  • 2021-07-08
  • 2021-11-30
  • 2022-01-25
  • 2021-12-29
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案