Database

[{"first_count":2,"second_count":1,"third_count":2,"test_count":2,"sido":"대구","guguns":[{"gugun":"남시","first_count":1,"second_count":1,"third_count":1},{"gugun":"부천군","first_count":1,"second_count":0,"third_count":1},{"gugun":"남시","test_count":1},{"gugun":"부천군","test_count":1}]}]

Query

db.collection.aggregate([{$unwind:"$guguns"},{$group:{_id:{_id:"$_id",gugun:"$guguns.gugun"},first_count:{$first:"$first_count"},second_count:{$first:"$second_count"},third_count:{$first:"$third_count"},test_count:{$first:"$test_count"},sido:{$first:"$sido"},guguns:{$mergeObjects:"$guguns"}}},{$group:{_id:"$_id._id",first_count:{$first:"$first_count"},second_count:{$first:"$second_count"},third_count:{$first:"$third_count"},test_count:{$first:"$test_count"},sido:{$first:"$sido"},guguns:{$push:"$guguns"}}}])

Result