MIN_BY() OVER ...

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

Returns the value of the first expression corresponding to the minimum value of the second expression in the window frame.

Syntax

Diagram(
  Sequence(
    Terminal("MIN_BY"),
    Terminal("("),NonTerminal('expr'), NonTerminal('key'),Terminal(")"),
    Terminal("OVER"),
    Terminal("("),
    NonTerminal("over_clause"),
    Terminal(")"),
  )
)
ParameterTypeRequiredDescription
exprEXPRESSIONYesValue expression to return for the minimum/maximum value
keyEXPRESSIONYesExpression to take the minimum/maximum value of
over_clauseOVER CLAUSEYesOVER (PARTITION BY ... ORDER BY ... [FRAME ...])

Notes

  • Returns value_expression for the row with minimum key_expression
  • Useful for finding associated values with minimum keys
  • Returns same type as first expression
  • NULL values in key are ignored
Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19