---
title: .sum()
slug: sum
docTags: 
createdAt: 2021-09-14T16:37:07.000Z
---

Returns the sum of all values of a [Sequence](docId\:JG4itlQWafzLpArttFo67) or [List](docId\:xWH_cUkHj9waqaEfb7H71).

- Operates on: [Sequence](docId\:JG4itlQWafzLpArttFo67) or [List](docId\:xWH_cUkHj9waqaEfb7H71)
- Returns: [Number](docId\:ucI5tCTfVBhonEJ6ZQijg), [Money](docId:_kS5D2xbfoR9d8WfRIVnY), [Percent](docId\:FbN7bFaHlFPV4f1C53DxA)

### Syntax

`.sum()`

- Returns the sum of the numeric elements of the List or Sequence

`.sum{expression}`

- Returns the sum of `expression`, evaluated against each of the elements of the List or Sequence.

### Examples

`db.job.find{dept:engineering}.sum{baseComp}` returns the total base compensation of everyone in the Engineering department.

`[1, 2, 3].sum()` returns `6`

`[1, 2, 3].sum{it * 2}` returns `12`
