How to group on multiple columns and sum up individual columns

Hi @Murali_Muppireddy, you would want to do something similar to the following:

{
    $group: {
        "_id": {
            X: "$X",
            Y_DT: "$Y_DT",
            Z: "$Z"
        },
        adj: {"$sum": "$adj"},
        bjc: {"$sum": "$bjc"},
        ...
    }
} 

Any non numeric value will be converted to 0 for the purposes of the $sum operation.

1 Like