नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
Applies to:
Databricks SQL
Databricks Runtime
Returns the last value of expr for the group of rows. The function is a synonym for last aggregate function.
Syntax
last_value(expr [, ignoreNull] ) [FILTER ( WHERE cond ) ] [ IGNORE NULLS | RESPECT NULLS ]
This function can also be invoked as a window function using the OVER clause.
Arguments
expr: An expression of any type.ignoreNull: An optionalBOOLEANliteral defaulting to false.cond: An optional boolean expression filtering the rows used for aggregation.IGNORE NULLSorRESPECT NULLS: WhenIGNORE NULLSis used orignoreNullistrue, anyexprvalue that isNULLis ignored. The default isRESPECT NULLS.
Returns
The result type matches expr.
This function is non-deterministic.
Examples
> SELECT last_value(col) FROM VALUES (10), (5), (20) AS tab(col);
20
> SELECT last_value(col) FROM VALUES (10), (5), (NULL) AS tab(col);
NULL
> SELECT last_value(col, true) FROM VALUES (10), (5), (NULL) AS tab(col);
5
> SELECT last_value(col) IGNORE NULLS FROM VALUES (10), (5), (NULL) AS tab(col);
5
> SELECT last_value(col) FILTER (WHERE col > 5) FROM VALUES (5), (20) AS tab(col);
20