0

enter image description here I have a mongoDB document having certain columns like Id, EmployeeID, SiteID, EmployeeAddress. A employee can be present at a site more than once. I want to have a group by query along with count which will give result set as

EmployeeID SiteID Count EmployeeAddress

basically how many times an employee is present as a site. I am using this query but not getting the desired data.

  db.pnr_dashboard.aggregate(
[
{ 
    "$group" : {
        "_id" : { "siteId" : "$siteId" , "employeeId" : "$employeeId"} , 
        "count" : { "$sum":1}},


} 
]
);
Sarthak Jain
  • 31
  • 1
  • 1
  • 6

0 Answers0