FIRST_VALUE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Window function syntax and usage

Returns the first value within an ordered group of values.

Syntax

supportedpartialnot supportednot scored

FIRST_VALUE( <expr> ) [ { IGNORE | RESPECT } NULLS ]
  OVER ( [ PARTITION BY <expr1> ] ORDER BY <expr2>  [ { ASC | DESC } ] [ NULLS { FIRST | LAST } ] [ <window_frame> ] )

Parameters

NameRequiredDescription
exprrequiredThe expression that determines the return value.
expr1requiredThe expression by which to partition the rows. You can specify a single expression or a comma-separated list of expressions. For example:Copy code PARTITION BY column_1, column_2
expr2requiredThe expression by which to order the rows. You can specify a single expression or a comma-separated list of expressions. For example:Copy code ORDER BY column_3, column_4
{ IGNORE | RESPECT } NULLSrequiredWhether to ignore or respect NULL values when an expr contains NULL values: IGNORE NULLS returns the first non-NULL value. RESPECT NULLS returns a NULL value if it is the first value in the expression. Default: RESPECT NULLS

Usage notes

See also

Referenced by