Database

[{"_id":ObjectId("5a934e000102030405000000"),"emp_name":"John","status":1,"type":"a1"},{"_id":ObjectId("5a934e000102030405000001"),"emp_name":"John","status":0,"type":"a1"},{"_id":ObjectId("5a934e000102030405000002"),"emp_name":"Jane","status":0,"type":"a1"},{"_id":ObjectId("5a934e000102030405000003"),"emp_name":"John","status":1,"type":"a2"},{"_id":ObjectId("5a934e000102030405000004"),"emp_name":"Jane","status":0,"type":"a2"},{"_id":ObjectId("5a934e000102030405000005"),"emp_name":"Bob","status":1,"type":"a1"},{"_id":ObjectId("5a934e000102030405000006"),"emp_name":"Bob","status":0,"type":"a2"},{"_id":ObjectId("5a934e000102030405000007"),"emp_name":"Bob","status":1,"type":"a2"}]

Query

db.collection.aggregate([{$facet:{"data":[{$match:{type:{$in:["a1","a2"]}}},{$group:{_id:{emp_name:"$emp_name",type:"$type"},count:{$sum:1}}},{$project:{empName:"$_id.emp_name",type:"$_id.type",count:1,_id:0}}/**ADD stages here with the mentioned condition*/]}}])

Result