> ## 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/avg-window",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

> Reference material for AVG function

# AVG OVER

Returns the average value within the requested window.

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"}}
AVG( <value> ) OVER ( [ PARTITION BY <partition_by> ] )
```

## Parameters

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

## Return Types

* `NUMERIC` if the input is type `INTEGER`, `BIGINT` or `NUMERIC`
* `DOUBLE PRECISION` if the input is type `REAL` or `DOUBLE PRECISION`

## Example

The example below is querying test scores for players in various game levels. Unlike a regular `AVG()` aggregation, the window function allows us to see how each student individually compares to the average test score for their game level.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
	nickname,
	level,
	currentscore,
	AVG(game_score) OVER (PARTITION BY level) AS score_average
FROM
	class_test;
```

**Returns**:

| nickname    | level | currentscore | score\_average |
| :---------- | :---- | :----------- | :------------- |
| kennethpark | 9     | 76           | 75.77777       |
| sabrina21   | 7     | 90           | 81.33333       |
| burchdenise | 8     | 79           | 79.55555       |
| ymatthews   | 6     | 85           | 93.88888       |
| rileyjon    | 8     | 80           | 84.99999       |
