Skip to main content
Skip to main content

last_value

Selects the last encountered value, similar to anyLast, but could accept NULL. Mostly it should be used with Window Functions. Without Window Functions the result will be random if the source stream is not ordered.

examples

example1

The NULL value is ignored at default.

example2

The NULL value is ignored.

example3

The NULL value is accepted.

example4

Stabilized result using the sub-query with ORDER BY.

Try ClickHouse Cloud for FREE

Easy data ingestion, automatic scaling, built-in SQL console and lots more.

Try it for Free