FIRST_VALUE

Description of first_value.eps follows

It returns the first value in an ordered set of values. If the first value in the set is null, then the function returns NULL unless you specify IGNORE NULLS. This setting is useful for data densification.

{RESPECT | IGNORENULLS determines whether null values of expr are included in or eliminated from the calculation. The default is RESPECT NULLS. If you specify IGNORE NULLS, then FIRST_VALUE returns the first non-null value in the set, or NULL if all values are null. Refer to “Using Partitioned Outer Joins: Examples” for an example of data densification.

SYNTAX

SELECT first_value(column_name) OVER (PARTITION BY partition_column ORDER BY order_column) AS result_alias
FROM your_table;

EXAMPLE 1: FIND THE FIRST SALE DATE FOR EACH PRODUCT

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top