I've an collection with 3 valuable fields (status, userid, sid).
How can i count rows for each smtpid and each status?
The status field can have values 0,1,2 or 3.
For example:
sid status userid
125 0 200
125 0 213
156 1 154
123 2 584
Purpose:
sid status count
125 0 2
156 1 1
123 2 1
Query for getting example:
{
runCommand : {
aggregate : 'sCollecion',
pipeline : [
{ $match : { time : { '$gte' : '2014-01-01 00:00:00', '$lt' : '2014-01-01 02:00:00' } } },
{ $group : { _id : { StatusID : '$status', SID : '$sid' , UserID : '$userid' } } }
]
}
}