Min
Builds a min(expression) expression, usable anywhere an SQL element is accepted (typically as a
Select column).
Constructor
Min(expression: any): Min
new Min(expression: any): Min
Dual-callable. expression is converted through the active SerializeContext (so a string,
literal, Field, or Raw are all accepted). Serializes to an empty string if expression is
falsy.
import { Min, Select } from '@sqb/builder';
Select('country', Min('age').as('youngest')).from('customers').groupBy('country');
// select country, min(age) youngest from customers group by country
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.MIN_STATEMENT | Yes | Discriminates this node during serialization. |
_expression | any | No | The argument passed to the constructor. |
_alias | string | undefined | No | Set by .as(). |
Methods
as()
as(alias: string): this
Sets an alias, rendered as a trailing alias after the closing paren (no AS keyword).
Min('age').as('youngest');
// min(age) youngest