WINDOW_FUNCTION_LAST_VALUE
WINDOW FUNCTION LAST_VALUEβ
descriptionβ
LAST_VALUE() returns the last value in the window range. Opposite of FIRST_VALUE() .
LAST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
exampleβ
Using the data from the FIRST_VALUE() example:
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