नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
Applies to: Databricks SQL
Databricks Runtime
Returns the first value of expr
for a group of rows. This function is a synonym for first_value
aggregate function.
Syntax
first(expr[, ignoreNull]) [FILTER ( WHERE cond ) ]
This function can also be invoked as a window function using the OVER
clause.
Arguments
expr
: An expression of any type.ignoreNull
: An optionalBOOLEAN
literal that defaults to false.cond
: An optional boolean expression filtering the rows used for aggregation.IGNORE NULLS
orRESPECT NULLS
: WhenIGNORE NULLS
is used orignoreNull
istrue
anyexpr
value that is NULL is ignored. The default isRESPECT NULLS
.
Returns
The result has the same type as expr
.
This function is non-deterministic.
Examples
> SELECT first(col) FROM VALUES (10), (5), (20) AS tab(col);
10
> SELECT first(col) FROM VALUES (NULL), (5), (20) AS tab(col);
NULL
> SELECT first(col, true) FROM VALUES (NULL), (5), (20) AS tab(col);
5
> SELECT first(col) IGNORE NULLS FROM VALUES (10), (5), (NULL) AS tab(col);
5
> SELECT first(col) FILTER (WHERE col > 5) FROM VALUES (5), (20) AS tab(col);
20