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

Separation of storage and compute, automatic scaling, built-in SQL console, and lots more. $300 in free credits when signing up.

Try it for Free