0

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

2
  • Can you please elaborate on your problem with an example? Commented Jul 9, 2020 at 16:43
  • @DeepakPatankar : Already elborated Commented Jul 9, 2020 at 16:52

1 Answer 1

1

#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
    }
);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.