Instruire
Modul
Write queries that use window functions - Training
This content is a part of Write queries that use window functions.
Acest browser nu mai este acceptat.
Faceți upgrade la Microsoft Edge pentru a profita de cele mai noi funcții, actualizări de securitate și asistență tehnică.
lead
analytic window functionApplies to: Databricks SQL
Databricks Runtime
Returns the value of expr
from a subsequent row within the partition. This function is a synonym to lag(expr, -offset, default)
.
lead(expr [, offset [, default] ] ) [ IGNORE NULLS | RESPECT NULLS ] OVER clause
expr
: An expression of any type.offset
: An optional INTEGER literal specifying the offset.default
: An expression of the same type as expr
.IGNORE NULLS
or RESPECT NULLS
: When IGNORE NULLS
is specified, any expr
value that is NULL is ignored. The default is RESPECT NULLS
.The result type matches expr
.
If offset
is positive the value originates from the row following the current row by offset
specified the ORDER BY in the OVER clause.
An offset of 0 uses the current row’s value.
A negative offset uses the value from a row preceding the current row.
If you do not specify offset
it defaults to 1, the immediately following row.
If there is no row at the specified offset within the partition the specified default
is used.
The default
default is NULL.
An ORDER BY clause must be provided.
> SELECT a, b, lead(b) OVER (PARTITION BY a ORDER BY b)
FROM VALUES ('A1', 2), ('A1', 1), ('A2', 3), ('A1', 1) tab(a, b);
A1 1 1
A1 1 2
A1 2 NULL
A2 3 NULL
Instruire
Modul
Write queries that use window functions - Training
This content is a part of Write queries that use window functions.
Documentație
lag analytic window function - Azure Databricks - Databricks SQL
Learn the syntax of the lag function of the SQL language in Databricks SQL and Databricks Runtime.
row_number ranking window function - Azure Databricks - Databricks SQL
Learn the syntax of the row\_number function of the SQL language in Databricks SQL and Databricks Runtime.
Window functions - Azure Databricks - Databricks SQL
Learn how to use window functions in the SQL language in Databricks SQL and Databricks Runtime.