Database

[{"N":0},{"N":20},{"N":0.01},{"N":50},{"N":10},{"N":20},{"N":0},{"N":11},{"N":35},{"N":51}]

Query

db.collection.aggregate([{$bucket:{groupBy:"$N",/** Field to group by*/boundaries:[0,1,10.1,20.1,30.1,1000],/** Boundaries for the buckets*/default:"Other",/** Bucket id for documents which do not fall into a bucket*/output:{/** Output for each bucket*/"count":{$sum:1},"data":{$push:{"N":"$N"}}}}},])

Result