Database

[{"cat_id":1,"categoryCode":"categoryCode1","categoryName":"categoryName1","cat":[{"type":"A"},{"type":"B"},{"type":"C"}]},{"cat_id":2,"categoryCode":"categoryCode1","categoryName":"categoryName1","cat":[{"type":"A"}]},{"cat_id":3,"categoryCode":"categoryCode2","categoryName":"categoryName2","cat":[{"type":"C"}]},{"cat_id":4,"categoryCode":"categoryCode3","categoryName":"categoryName3","cat":[{"type":"A"}]}]

Query

db.collection.aggregate([{$group:{_id:{"categoryCode":"$categoryCode","categoryName":"$categoryName"},"cat_count":{$sum:{$cond:[{$in:["A","$cat.type"]},1,0]}}}},{$project:{"_id":0,"categoryCode":"$_id.categoryCode","categoryName":"$_id.categoryName","cat_count":"$cat_count"}}])

Result