mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
a278d13043
remove redundant 's'
56 lines
1.1 KiB
Markdown
56 lines
1.1 KiB
Markdown
---
|
|
slug: /en/sql-reference/aggregate-functions/reference/first_value
|
|
sidebar_position: 7
|
|
---
|
|
|
|
# first_value
|
|
|
|
Selects the first encountered value, similar to `any`, but could accept NULL.
|
|
|
|
## examples
|
|
|
|
```sql
|
|
insert into test_data (a,b) values (1,null), (2,3), (4, 5), (6,null)
|
|
```
|
|
|
|
### example1
|
|
The NULL value is ignored at default.
|
|
```sql
|
|
select first_value(b) from test_data
|
|
```
|
|
|
|
```text
|
|
┌─first_value_ignore_nulls(b)─┐
|
|
│ 3 │
|
|
└─────────────────────────────┘
|
|
|
|
```
|
|
|
|
### example2
|
|
The NULL value is ignored.
|
|
```sql
|
|
select first_value(b) ignore nulls from test_data
|
|
```
|
|
|
|
```text
|
|
┌─first_value_ignore_nulls(b)─┐
|
|
│ 3 │
|
|
└─────────────────────────────┘
|
|
|
|
```
|
|
|
|
### example3
|
|
The NULL value is accepted.
|
|
```sql
|
|
select first_value(b) respect nulls from test_data
|
|
```
|
|
|
|
```text
|
|
|
|
┌─first_value_respect_nulls(b)─┐
|
|
│ ᴺᵁᴸᴸ │
|
|
└──────────────────────────────┘
|
|
```
|
|
|
|
|