Description
Returns the first value in an ordered set of values
Syntax
FIRST_VALUE(expression)
Parameters
| Parameter | Description | Data Type | Required |
|---|---|---|---|
| expression | Column or expression to evaluate | Any | Yes |
Rewrite
Use QUALIFY to filter on window expression results; do not use window functions in WHERE.
Notes
- Include an
OVER (...)clause withORDER BY(and optionalPARTITION BY) when using this as a window function.
Example
SELECT
id, FIRST_VALUE(full_name) OVER (PARTITION BY department ORDER BY start_date) AS first_name
FROM
rippling.employee.Employee;