Thank @Doug_Duncan, I could able to get the expected results…
with the following query…
db.test650.aggregate(
{
$group: {
"_id": {
X: "$X",
Y_DT: "$Y_DT",
Z: "$Z"
},
adj: {$sum: "$adj" },
bjc: {$sum: "$bjc" },
jbc: {$sum: "$jbc" },
mnk: {$sum: "$mnk"}
}
}
)
But in case of bigger collection with many number of fields, say like 500, it will be very complex to write all the filed names and sumup, is there any generic way we can write some thing like looping rest of the fields(other than grouping ones)?