Skip to main content
Skip to main content

last_value

Returns the last value evaluated within its ordered frame. By default, NULL arguments are skipped, however the RESPECT NULLS modifier can be used to override this behaviour.

Syntax

Alias: anyLast.

Note

Using the optional modifier RESPECT NULLS after first_value(column_name) will ensure that NULL arguments are not skipped. See NULL processing for more information.

Alias: lastValueRespectNulls

For more detail on window function syntax see: Window Functions - Syntax.

Returned value

  • The last value evaluated within its ordered frame.

Example

In this example the last_value function is used to find the lowest paid footballer from a fictional dataset of salaries of Premier League football players.

Query:

Result: