mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
988 B
988 B
slug | sidebar_position |
---|---|
/en/sql-reference/aggregate-functions/reference/last_value | 8 |
first_value
Selects the last encountered value, similar to anyLast
, but could accept NULL.
examples
insert into test_data (a,b) values (1,null), (2,3), (4, 5), (6.null)
example1
The NULL value is ignored at default.
select last_value(b) from test_data
┌─last_value(b)─┐
│ 5 │
└───────────────┘
example2
The NULL value is ignored.
select last_value(false)(b) from test_data
┌─last_value(false)(b)─┐
│ 5 │
└──────────────────────┘
example3
The NULL value is accepted.
select last_value(true)(b) from test_data
┌─last_value(true)(b)─┐
│ ᴺᵁᴸᴸ │
└─────────────────────┘