MongoDB - 不能除以零错误

时间:2017-11-09 05:52:20

标签: mongodb mongodb-query

试图找出我收到此错误的原因,我的代码在

之下
db.assign1.aggregate([
{$unwind: "$courses"},
{$match: {status: "active"}},
{$group: {_id: {"Course Code": "$courses.code"},
         "Total Questions": {$sum: "$courses.total_questions"},
         "Correct Answers": {$sum: "$courses.correct_answers"}}},
{$project: {_id: 0,
           "Course Code": 1,
           "Total Questions:": 1,
           "Correct Answers": 1,
           "% Correct": {$divide: [{$sum: "$courses.correct_answers"},{$sum: "$courses.correct_answers"}]}}}

0 个答案:

没有答案