db.user_status.aggregate([ { $unwind : "$2018-02-17.error"},{$match:{"2018-02-17.record":4}},{ $project : {_id:0,"2018-02-17.error":1}},{$group:{_id:"$2018-02-17.error",total:{$sum:1}}}]);
{ "_id" : "2018-02-17-3", "total" : 15 }
{ "_id" : "2018-02-17-1", "total" : 920 }
{ "_id" : "2018-02-17-5", "total" : 38 }
{ "_id" : "2018-02-17-4", "total" : 18 }
{ "_id" : "2018-02-17-2", "total" : 16 }
每日答题情况:
"2018-02-15"
5360答题 3259全对
"2018-02-16"
3450答题 2107全对
"2018-02-17"
2789答题 1398全对
"2018-02-18"
2873答题 2083全对
"2018-02-19"
2617答题 2058全对
db.user_status.aggregate([ { $unwind : "$2018-02-19.record"},{$match:{"2018-02-19.record":{$exists:true}}},{ $project : {_id:0,"2018-02-19.record":1}},{$group:{_id:"$2018-02-19.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
{ "_id" : 0, "total" : 5 }
{ "_id" : 1, "total" : 35 }
{ "_id" : 2, "total" : 49 }
{ "_id" : 3, "total" : 97 }
{ "_id" : 4, "total" : 373 }
{ "_id" : 5, "total" : 2058 }
db.user_status.aggregate([ { $unwind : "$2018-02-18.record"},{$match:{"2018-02-18.record":{$exists:true}}},{ $project : {_id:0,"2018-02-18.record":1}},{$group:{_id:"$2018-02-18.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
{ "_id" : 0, "total" : 12 }
{ "_id" : 1, "total" : 41 }
{ "_id" : 2, "total" : 79 }
{ "_id" : 3, "total" : 232 }
{ "_id" : 4, "total" : 426 }
{ "_id" : 5, "total" : 2083 }
db.user_status.aggregate([ { $unwind : "$2018-02-17.record"},{$match:{"2018-02-17.record":{$exists:true}}},{ $project : {_id:0,"2018-02-17.record":1}},{$group:{_id:"$2018-02-17.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
{ "_id" : 0, "total" : 24 }
{ "_id" : 1, "total" : 58 }
{ "_id" : 2, "total" : 107 }
{ "_id" : 3, "total" : 195 }
{ "_id" : 4, "total" : 1007 }
{ "_id" : 5, "total" : 1398 }
db.user_status.aggregate([ { $unwind : "$2018-02-16.record"},{$match:{"2018-02-16.record":{$exists:true}}},{ $project : {_id:0,"2018-02-16.record":1}},{$group:{_id:"$2018-02-16.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
{ "_id" : 0, "total" : 61 }
{ "_id" : 1, "total" : 116 }
{ "_id" : 2, "total" : 150 }
{ "_id" : 3, "total" : 275 }
{ "_id" : 4, "total" : 741 }
{ "_id" : 5, "total" : 2107 }
db.user_status.aggregate([ { $unwind : "$2018-02-15.record"},{$match:{"2018-02-15.record":{$exists:true}}},{ $project : {_id:0,"2018-02-15.record":1}},{$group:{_id:"$2018-02-15.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
{ "_id" : 0, "total" : 27 }
{ "_id" : 1, "total" : 104 }
{ "_id" : 2, "total" : 228 }
{ "_id" : 3, "total" : 514 }
{ "_id" : 4, "total" : 1228 }
{ "_id" : 5, "total" : 3259 }
db.user_status.aggregate([ { $unwind : "$2018-02-19.record"},{$match:{"2018-02-19.record":{$exists:true}}},{ $project : {_id:0,"2018-02-19.record":1}},{$group:{_id:"$2018-02-19.record",total:{$sum:1}}},{$sort:{"_id":1}}]);
db.user_status.find({"2018-02-15":{$exists:true},"2018-02-16":{$exists:true},"2018-02-17":{$exists:true},"2018-02-18":{$exists:true},"2018-02-19":{$exists:true}}).count()
655人连续五天全部参与答题
db.user_status.find({"2018-02-15":{$exists:true},"2018-02-16":{$exists:true},"2018-02-17":{$exists:true},"2018-02-18":{$exists:true}}).count()
874人前四天连续参与答题
db.user_status.find({"2018-02-15":{$exists:true},"2018-02-16":{$exists:true},"2018-02-17":{$exists:true}}).count()
1184人前三天连续参与答题
db.user_status.aggregate([ { $unwind : "$2018-02-21.record"},{$match:{"2018-02-21.record":{$exists:true}}},{ $project : {_id:0,"2018-02-21.record":1}},{$group:{_id:"$2018-02-21.record",total:{$sum:1}}},{$sort:{"_id":1}}]);