Max
Builds a max(expression) expression, usable anywhere an SQL element is accepted (typically as a
Select column).
Constructor
Max(expression: any): Max
new Max(expression: any): Max
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 { Max, Select } from '@sqb/builder';
Select('country', Max('age').as('oldest')).from('customers').groupBy('country');
// select country, max(age) oldest from customers group by country
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.MAX_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).
Max('age').as('oldest');
// max(age) oldest