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"//将结果输出到数据集中
}
]);
时间: 2024-10-14 06:23:10