WINDOW-FUNCTION-LAST_VALUE
WINDOW FUNCTION LAST_VALUE
description
LAST_VALUE() 返回窗口范围内的最后一个值。与 FIRST_VALUE() 相反。
LAST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
example
使用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