Reputation: 728
How to perform count on a particular column value with multiple match condition with aggregation. How to count EmpId in DeptId 1 and TimeCode 22
Empid DeptId TimeCode
1 1 22
2 1 25
3 1 22
4 2 22
5 1 21
Upvotes: 0
Views: 39
Reputation: 728
#Example in mongo to count number of employees in perticular department.
db.getCollection("Employee").aggregate(
[
{
"$match" : {
"DeptId " : 1
}
},
{
"$match" : {
"TimeCode" : 22
}
},
{
"$count" : "EmployeeId"
}
],
{
"allowDiskUse" : false
}
);
Upvotes: 1