VeloDB Cloud
SQL Manual
Functions
window-functions
WINDOW-FUNCTION-LAST_VALUE

WINDOW FUNCTION LAST_VALUE

Description

This function returns the last value in the window, which is the opposite of FIRST_VALUE().

LAST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])

Example

The same example from FIRST_VALUE():

select country, name,    
last_value(greeting)   
over (partition by country order by name, greeting) as greeting   
from mail_merge;
 
| country | name    | greeting     |
|---------|---------|--------------|
| Germany | Boris   | Guten morgen |
| Germany | Michael | Guten morgen |
| Sweden  | Bjorn   | Tja          |
| Sweden  | Mats    | Tja          |
| USA     | John    | Hello        |
| USA     | Pete    | Hello        |

Keywords

WINDOW,FUNCTION,LAST_VALUE