我在MongoDB中此聚集查詢:
db.questions.aggregate([
{ $project:{question:1,detail:1, choices:1, answer:1,
percent_false:{
$multiply:[100,{$divide:["$answear_false",{$add:["$answear_false","$answear_true"]}]}]},
percent_true:{
$multiply:[100,{$divide:["$answear_true",{$add:["$answear_false","$answear_true"]}]}]} }}, {$match:{status:'active'} }
]).pretty()
我想用$比賽2個計算領域 「percent_true」 和 「percent_false」 像這樣
$match : {percent_true:{$gte:20}}
我能怎麼做 ?
{$ match:{percent_true:{$ gte:20},anotherField:{$ lte:10},yetAnotherField:12345}},no? – joao
您的代碼塊是真的很難看。您能否再投入更多精力在下一次縮進? –