Skip to main content

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

KeyTypeReadonlyDescription
_typeSerializationType.MIN_STATEMENTYesDiscriminates this node during serialization.
_expressionanyNoThe argument passed to the constructor.
_aliasstring | undefinedNoSet 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

See also