WINDOW FUNCTION LAST_VALUE

description

LAST_VALUE() returns the last value in the window range. Opposite of FIRST_VALUE() .

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

example

Using the data from the FIRST_VALUE() example:

1. select country, name,
2. last_value(greeting)
3. over (partition by country order by name, greeting) as greeting
4. from mail_merge;

6. | country | name    | greeting     |
7. |---------|---------|--------------|
8. | Germany | Boris   | Guten morgen |
9. | Germany | Michael | Guten morgen |
10. | Sweden  | Bjorn   | Tja          |
11. | Sweden  | Mats    | Tja          |
12. | USA     | John    | Hello        |
13. | USA     | Pete    | Hello        |

keywords

1. WINDOW,FUNCTION,LAST_VALUE