Spring Boot and MongoTemplate: How to Use Sum with Group in Aggregations Fortunately, MongoDB lets you get the sum of all field values in an aggregation group. And you can handle that with MongoTemplate in Spring Boot.