Skip to content

Commit

Permalink
Merge pull request #4302 from soerenwolfers/patch-66
Browse files Browse the repository at this point in the history
Update aggregates.md
  • Loading branch information
szarnyasg authored Dec 8, 2024
2 parents cffe3e0 + 5a3b837 commit 9c41c6f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions docs/sql/functions/aggregates.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ FROM tbl;
|-----------|
| 3, 2, 1 |


### Handling `NULL` Values

All general aggregate functions except for [`list`](#listarg) and [`first`](#firstarg) (and their aliases [`array_agg`](#array_aggarg) and [`arbitrary`](#arbitraryarg), respectively) ignore `NULL`s.
To exclude `NULL`s from `list`, you can use a [`FILTER` clause]({% link docs/sql/query_syntax/filter.md %}).
To ignore `NULL`s from `first`, you can use the [`any_value` aggregate](#any_valuearg).

All general aggregate functions except [`count`](#countarg) return `NULL` on empty groups.
In particular, [`list`](#listarg) does *not* return an empty list, [`sum`](#sumarg) does *not* return zero, and [`string_agg`](#string_aggarg-sep) does *not* return an empty string in this case.

## General Aggregate Functions

The table below shows the available general aggregate functions.
Expand Down Expand Up @@ -448,15 +458,6 @@ The table below shows the available general aggregate functions.
| **Example** | `sum(A)` |
| **Alias(es)** | - |

### Handling `NULL` Values

All general aggregate functions except for [`list`](#listarg) and [`first`](#firstarg) (and their aliases [`array_agg`](#array_aggarg) and [`arbitrary`](#arbitraryarg), respectively) ignore `NULL`s.
To exclude `NULL`s from `list`, you can use a [`FILTER` clause]({% link docs/sql/query_syntax/filter.md %}).
To ignore `NULL`s from `first`, you can use the [`any_value` aggregate](#any_valuearg).

All general aggregate functions except [`count`](#countarg) return `NULL` on empty groups and groups without non-`NULL` inputs.
In particular, [`list`](#listarg) does *not* return an empty list, [`sum`](#sumarg) does *not* return zero, and [`string_agg`](#string_aggarg-sep) does *not* return an empty string in this case.

## Approximate Aggregates

The table below shows the available approximate aggregate functions.
Expand Down

0 comments on commit 9c41c6f

Please sign in to comment.