> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/window/sum-window",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for SUM function

# SUM OVER

Calculate the sum of the values within the requested window.

The SUM function works with numeric values and ignores `NULL` values.

For more information on usage, please refer to [Window Functions](/reference-sql/functions-reference/window).

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SUM([ DISTINCT ] <value> ) OVER ( [ PARTITION BY <partition_by> ] )
```

## Parameters

| Parameter        | Description                                      | Supported input types |
| :--------------- | :----------------------------------------------- | :-------------------- |
| `<value>`        | The expression used for the `SUM` function       | Any numeric type      |
| `<partition_by>` | An expression used for the `PARTITION BY` clause | Any                   |

## Return Types

`NUMERIC`

When `DISTINCT` is specified, duplicate values from `<expression>` are removed before calculating the sum.

## Example

The example below shows how many players are on a specific level.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
	level,
	SUM(players) OVER (PARTITION BY level ) AS current_players
FROM
	players;
```

**Returns**:

| level | current\_players |
| :---- | :--------------- |
| 1     | 156              |
| 2     | 108              |
| 3     | 127              |
| 4     | 198              |
| 5     | 207              |
