FIRST_VALUE() OVER ...

All functions > WINDOW FUNCTION > FIRST_VALUE() OVER ...

Returns the first value in the window frame.

Syntax

Diagram(
  Sequence(
    Terminal("FIRST_VALUE"),
    Terminal("("),NonTerminal('expr'),Terminal(")"),
    Terminal("OVER"),
    Terminal("("),
    NonTerminal("over_clause"),
    Terminal(")"),
  )
)
ParameterTypeRequiredDescription
exprEXPRESSIONYesExpression to get the first/last value of
over_clauseOVER CLAUSEYesOVER (PARTITION BY ... ORDER BY ... [FRAME ...])

Notes

  • Returns the value from the first row of the window frame
  • ORDER BY determines which row is considered "first"
  • PARTITION BY divides rows into independent groups
  • Window frame controls which rows are considered
  • Default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  • Returns same type as input expression
  • Useful for comparing current row with first row in partition
  • NULL values are preserved
Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19