Database
[{"amount":{"$numberDecimal":"1"},"appId":3,"createdDttm":{"$date":"2023-09-15T10:17:41.350Z"},"day":15,"hour":10,"month":9,"newUser":true,"userId":"11111","year":2023},{"amount":{"$numberDecimal":"10"},"appId":3,"createdDttm":{"$date":"2023-09-15T16:17:41.350Z"},"day":15,"hour":16,"month":9,"newUser":true,"userId":"11111","year":2023},{"amount":{"$numberDecimal":"100"},"appId":7,"createdDttm":{"$date":"2023-09-16T16:00:01.135Z"},"day":16,"hour":16,"month":9,"userId":"11111","year":2023},{"amount":{"$numberDecimal":"2"},"appId":5,"createdDttm":{"$date":"2023-09-15T16:00:41.100Z"},"day":15,"hour":16,"month":9,"newUser":true,"userId":"22222","year":2023}]
Query
db.collection.aggregate([{$match:/*** query: The query in MQL.*/{year:2023,month:9,day:15,newUser:true}},{"$group":{"_id":"$appId","count":{$sum:1}}},{"$project":{_id:0,appId:"$_id",count:1}}])