我在这个聚合中需要帮助,
db.billingcycles.aggregate([{
$project:{credit:{$sum:”$credits.value”},debt:{$sum: “debts.value”}},
}, {
$group:{_id:null,credits:{$sum:”$credit”},debt:{$sum:”$debt”}}
}])
错误:2017-10-13T00:23:16.375-0300 E QUERY [thread1]语法错误:非法字符@(shell):2:23
答案 0 :(得分:0)
试试这个
db.billingcycles.aggregate([{
$group: {
"credit": {
$sum: ”$credits.value”
},
"debt": {
$sum: "$debts.value"
}
}
}, {
$project: {
"_id": null,
"credit": 1,
"debt": 1
}
}]