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(")"),
)
)| Parameter | Type | Required | Description |
|---|---|---|---|
expr | EXPRESSION | Yes | Value expression to return for the minimum/maximum value |
key | EXPRESSION | Yes | Expression to take the minimum/maximum value of |
over_clause | OVER CLAUSE | Yes | OVER (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