Database
[{"_id":"1","customerName":"ABC",},{"_id":"2","customerName":"ABC",},{"_id":"3","customerName":"Another",}]
Query
db.collection.aggregate([{"$group":{"_id":"$customerName",result:{"$sum":1}}},{$sort:{result:-1}}])